Skip to content
Snippets Groups Projects
Select Git revision
  • f88e4b8320c34894aa6b1c05a9509f62ba29b704
  • master default protected
  • dev
  • appimage
  • fix_gitlab
  • fixappveyor
  • gitlab
  • fix_ci
  • fix_dbus_error
  • fix_ci_osx
  • sakia020
  • fix_travis#1105
  • feature/backend
  • check_uniq_node_by_endpoints
  • qt5.7
  • feature/agent_architecture
  • translations
  • pyqt5.6
  • qtwebengine
  • pyinstaller
  • landscape
  • 0.53.2
  • 0.53.1
  • 0.53.0
  • 0.52.0
  • 0.51.1
  • 0.51.0
  • 0.50.5
  • 0.50.4
  • 0.50.3
  • 0.50.2
  • 0.50.1
  • 0.50.0
  • 0.33.0rc7
  • 0.33.0rc6
  • 0.33.0rc5
  • 0.33.0rc4
  • 0.33.0rc3
  • 0.33.0rc2
  • 0.33.0rc1
  • 0.32.10post1
41 results

identities.py

Blame
  • mock.rs 3.62 KiB
    // Copyright 2023 Axiom-Team
    //
    // This file is part of Duniter-v2S.
    //
    // Duniter-v2S is free software: you can redistribute it and/or modify
    // it under the terms of the GNU Affero General Public License as published by
    // the Free Software Foundation, version 3 of the License.
    //
    // Duniter-v2S is distributed in the hope that it will be useful,
    // but WITHOUT ANY WARRANTY; without even the implied warranty of
    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    // GNU Affero General Public License for more details.
    //
    // You should have received a copy of the GNU Affero General Public License
    // along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>.
    
    use crate::runtime::runtime_types::{
        pallet_distance::median::MedianAcc, sp_arithmetic::per_things::Perbill,
    };
    
    use dubp_wot::{data::rusty::RustyWebOfTrust, WebOfTrust, WotId};
    use sp_core::H256;
    use std::collections::BTreeSet;
    
    pub struct Client {
        wot: RustyWebOfTrust,
        pub pool_len: usize,
    }
    pub type AccountId = subxt::ext::sp_runtime::AccountId32;
    pub type IdtyIndex = u32;
    
    pub struct EvaluationPool<AccountId: Ord, IdtyIndex> {
        pub evaluations: (Vec<(IdtyIndex, MedianAcc<Perbill>)>,),
        pub evaluators: BTreeSet<AccountId>,
    }
    
    pub async fn client(_rpc_url: String) -> Client {
        unimplemented!()
    }
    
    pub fn client_from_wot(wot: RustyWebOfTrust) -> Client {
        Client { wot, pool_len: 1 }
    }
    
    pub async fn parent_hash(_client: &Client) -> H256 {
        Default::default()
    }
    
    pub async fn current_pool_index(_client: &Client, _parent_hash: H256) -> u32 {
        0
    }
    
    pub async fn current_pool(
        client: &Client,
        _parent_hash: H256,
        _current_session: u32,
    ) -> Option<EvaluationPool<AccountId, IdtyIndex>> {
        Some(EvaluationPool {
            evaluations: (client
                .wot
                .get_enabled()
                .into_iter()
                .chain(client.wot.get_disabled().into_iter())
                .zip(0..client.pool_len)
                .map(|(wot_id, _)| {
                    (wot_id.0 as IdtyIndex, unsafe {
                        std::mem::transmute((Vec::<()>::new(), Option::<u32>::None, 0))
                    })
                })
                .collect(),),