Skip to content
Snippets Groups Projects
Select Git revision
  • db77163438f2861a91952a22758aa6b86eea435a
  • master default protected
  • network/gdev-800 protected
  • cgeek/issue-297-cpu
  • gdev-800-tests
  • update-docker-compose-rpc-squid-names
  • fix-252
  • 1000i100-test
  • hugo/tmp-0.9.1
  • network/gdev-803 protected
  • hugo/endpoint-gossip
  • network/gdev-802 protected
  • hugo/distance-precompute
  • network/gdev-900 protected
  • tuxmain/anonymous-tx
  • debug/podman
  • hugo/195-doc
  • hugo/195-graphql-schema
  • hugo-tmp-dockerfile-cache
  • release/client-800.2 protected
  • release/runtime-800 protected
  • gdev-900-0.10.1 protected
  • gdev-900-0.10.0 protected
  • gdev-900-0.9.2 protected
  • gdev-800-0.8.0 protected
  • gdev-900-0.9.1 protected
  • gdev-900-0.9.0 protected
  • gdev-803 protected
  • gdev-802 protected
  • runtime-801 protected
  • gdev-800 protected
  • runtime-800-bis protected
  • runtime-800 protected
  • runtime-800-backup protected
  • runtime-701 protected
  • runtime-700 protected
  • runtime-600 protected
  • runtime-500 protected
  • v0.4.1 protected
  • runtime-401 protected
  • v0.4.0 protected
41 results

compilation.md

Blame
  • queries.rs 2.55 KiB
    //  Copyright (C) 2020 Éloïs SANCHEZ.
    //
    // 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/>.
    
    pub mod account_balance;
    pub mod block;
    pub mod current_block;
    pub mod current_frame;
    pub mod first_utxos_of_scripts;
    pub mod gen_tx;
    pub mod idty;
    pub mod network;
    pub mod txs_history;
    pub mod uds;
    pub mod utxos_of_script;
    pub mod wallets;
    
    use crate::*;
    
    #[derive(async_graphql::MergedObject, Default)]
    pub struct QueryRoot(
        queries::NodeQuery,
        queries::account_balance::AccountBalanceQuery,
        queries::block::BlockQuery,
        queries::current_block::CurrentBlockQuery,
        queries::current_frame::CurrentFrameQuery,
        queries::first_utxos_of_scripts::FirstUtxosQuery,
        queries::gen_tx::GenTxsQuery,
        queries::idty::IdtyQuery,
        queries::network::NetworkQuery,
        queries::txs_history::TxsHistoryBlockchainQuery,
        queries::txs_history::TxsHistoryMempoolQuery,
        queries::uds::UdsQuery,
        queries::utxos_of_script::UtxosQuery,
        queries::wallets::WalletsQuery,
    );
    
    #[derive(Default, async_graphql::SimpleObject)]
    struct NodeQuery {
        node: Node,
    }
    
    #[derive(Default)]
    struct Node;
    
    #[async_graphql::Object]
    impl Node {
        /// Peer card
        async fn peer(
            &self,
            ctx: &async_graphql::Context<'_>,
        ) -> async_graphql::Result<Option<PeerCardGva>> {
            let data = ctx.data::<GvaSchemaData>()?;
    
            if let Some(self_peer_old) = data
                .cm_accessor()
                .get_self_peer_old(|self_peer_old| self_peer_old.clone())
                .await
            {
                Ok(Some(PeerCardGva::from(self_peer_old)))
            } else {
                Ok(None)
            }
        }
        /// Software
        async fn software(&self) -> &'static str {
            duniter_core::module::SOFTWARE_NAME
        }
        /// Software version
        async fn version(
            &self,
            ctx: &async_graphql::Context<'_>,
        ) -> async_graphql::Result<&'static str> {
            let data = ctx.data::<GvaSchemaData>()?;
            Ok(data.server_meta_data.software_version)
        }
    }