Skip to content
Snippets Groups Projects
Select Git revision
  • dec5bfba9922c5e7a636a7304039c2e3de11d69a
  • dev default protected
  • vainamoinen197-transactiondocument-replace-vec-fields-by-smallvec-2
  • dvermd/200-keypairs-dewif
  • elois/wot
  • jawaka/155-dbex-add-dump-fork-tree-command
  • elois/195-bcdbwriteop
  • elois/deps-crypto
  • elois/gva-monetary-mass
  • elois/191-sled
  • elois/195
  • ji_emme/gva-humantimefield
  • 184-gva-rename-commontime-field-to-blockchaintime
  • ji_emme/182-gva-implement-block-meta-data
  • ji_emme/rml14
  • hugo/151-ws2pv2-sync
  • ji_emme/181-gva-implement-identity-request
  • ji_emme/89-implement-client-api-gva-graphql-verification-api
  • logo
  • test-juniper-from-schema
  • elois/exemple-gva-global-context
  • v0.2.0-a4 protected
  • v0.2.0-a2 protected
  • v0.2.0-a protected
  • v0.1.1-a1 protected
  • documents/v0.10.0-b1 protected
  • crypto/v0.4.0-b1 protected
  • crypto/v0.3.0-b3 protected
  • crypto/v0.3.0-b2 protected
  • crypto/v0.3.0-b1 protected
  • wot/v0.8.0-a0.9 protected
  • wot/v0.8.0-a0.8 protected
  • 0.1.0-a0.1 protected
  • v0.0.1-a0.12 protected
  • v0.0.1-a0.11 protected
  • v0.0.1-a0.10 protected
  • v0.0.1-a0.9 protected
  • v0.0.1-a0.8 protected
  • v0.0.1-a0.7 protected
  • v0.0.1-a0.6 protected
  • v0.0.1-a0.5 protected
41 results

dal_requests.rs

Blame
  • dal_requests.rs 3.80 KiB
    //  Copyright (C) 2018  The Duniter Project Developers.
    //
    // This program 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, either version 3 of the
    // License, or (at your option) any later version.
    //
    // This program 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 this program.  If not, see <https://www.gnu.org/licenses/>.
    
    extern crate duniter_module;
    extern crate serde;
    
    use self::duniter_module::ModuleReqId;
    use duniter_documents::v10::block::BlockDocument;
    use duniter_documents::v10::certification::CertificationDocument;
    use duniter_documents::v10::identity::IdentityDocument;
    use duniter_documents::v10::membership::MembershipDocument;
    use duniter_documents::v10::revocation::RevocationDocument;
    use duniter_documents::Blockstamp;
    use dup_crypto::hashs::Hash;
    use dup_crypto::keys::*;
    use std::collections::HashMap;
    
    #[derive(Debug, Copy, Clone)]
    /// Inter-module DAL request for pool data
    pub enum DALReqPendings {
        /// All pending identities with their pending certifications
        AllPendingIdentities(usize),
        /// All pending identities without their pending certifications
        AllPendingIdentitiesWithoutCerts(usize),
        /// All pending datas for given pubkey
        PendingWotDatasForPubkey(PubKey),
    }
    
    #[derive(Debug, Clone, PartialEq)]
    /// Inter-module DAL request for blockchain data
    pub enum DALReqBlockchain {
        /// Current block
        CurrentBlock(),
        /// Block by number
        BlockByNumber(u64),
        /// Chunk (block pack)
        Chunk(u64, usize),
        /// Usernames corresponding to the public keys in parameter
        UIDs(Vec<PubKey>),
    }
    
    #[derive(Debug, Clone)]
    /// Inter-module DAL request
    pub enum DALRequest {
        /// Inter-module DAL request for blockchain data
        BlockchainRequest(DALReqBlockchain),
        /// Inter-module DAL request for pool data
        PendingsRequest(DALReqPendings),
    }
    
    #[derive(Debug, Clone)]
    /// Pending identity datas
    pub struct PendingIdtyDatas {
        /// Identity document
        pub idty: IdentityDocument,
        /// Membership document
        pub memberships: Vec<MembershipDocument>,
        /// Number of certifications received
        pub certs_count: usize,
        /// Certifications documents
        pub certs: Vec<CertificationDocument>,
        /// Revocation document (None if identity has not been revoked)
        pub revocation: Option<RevocationDocument>,
    }
    
    #[derive(Debug, Clone)]
    /// Response to a DALReqPendings request
    pub enum DALResPendings {
        /// All pending identities with their pending certifications
        AllPendingIdentities(ModuleReqId, HashMap<Hash, PendingIdtyDatas>),
        /// All pending identities without their pending certifications
        AllPendingIdentitiesWithoutCerts(ModuleReqId, HashMap<Hash, PendingIdtyDatas>),
        /// All pending datas for given pubkey
        PendingWotDatasForPubkey(ModuleReqId, Box<PendingIdtyDatas>),
    }
    
    #[derive(Debug, Clone)]
    /// Response to a DALReqBlockchain request
    pub enum DALResBlockchain {
        /// Current block
        CurrentBlock(ModuleReqId, Box<BlockDocument>, Blockstamp),
        /// Block by number
        BlockByNumber(ModuleReqId, Box<BlockDocument>),
        /// Chunk (block pack)
        Chunk(ModuleReqId, Vec<BlockDocument>),
        /// Usernames corresponding to the public keys in parameter
        UIDs(ModuleReqId, HashMap<PubKey, Option<String>>),
    }
    
    #[derive(Debug, Clone)]
    /// Response to a DAL request
    pub enum DALResponse {
        /// Response to a DALReqBlockchain request
        Blockchain(Box<DALResBlockchain>),
        /// Response to a DALReqPendings request
        Pendings(Box<DALResPendings>),
    }