diff --git a/rust-libs/modules/gva/bca/src/exec_req_type.rs b/rust-libs/modules/gva/bca/src/exec_req_type.rs index 6a4b226c71e8006d7b395f1b3f24ee025380ec24..fc6c927493577b8308f4eb407be44ee10dca7400 100644 --- a/rust-libs/modules/gva/bca/src/exec_req_type.rs +++ b/rust-libs/modules/gva/bca/src/exec_req_type.rs @@ -14,6 +14,7 @@ // along with this program. If not, see <https://www.gnu.org/licenses/>. mod balances; +mod current_ud; mod last_blockstamp_out_of_fork_window; mod members_count; mod prepare_simple_payment; @@ -90,5 +91,6 @@ pub(super) async fn execute_req_type( .await??, )) } + BcaReqTypeV0::CurrentUd => current_ud::exec_req_current_ud(bca_executor).await, } } diff --git a/rust-libs/modules/gva/bca/src/exec_req_type/current_ud.rs b/rust-libs/modules/gva/bca/src/exec_req_type/current_ud.rs new file mode 100644 index 0000000000000000000000000000000000000000..02823dbbaf3d8a6b07cc623198c03511389bf5c9 --- /dev/null +++ b/rust-libs/modules/gva/bca/src/exec_req_type/current_ud.rs @@ -0,0 +1,30 @@ +// 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/>. + +use crate::*; + +pub(super) async fn exec_req_current_ud( + bca_executor: &BcaExecutor, +) -> Result<BcaRespTypeV0, ExecReqTypeError> { + if let Some(current_ud) = bca_executor + .cm_accessor + .get_current_meta(|cm| cm.current_ud) + .await + { + Ok(BcaRespTypeV0::CurrentUd(current_ud)) + } else { + Err("no blockchain".into()) + } +} diff --git a/rust-libs/modules/gva/bca/types/src/lib.rs b/rust-libs/modules/gva/bca/types/src/lib.rs index 4182fb555e9fae5c6c3095c59660a50500d8bd78..4cc715f0593a74597bc4a516ab42e7e58733d61f 100644 --- a/rust-libs/modules/gva/bca/types/src/lib.rs +++ b/rust-libs/modules/gva/bca/types/src/lib.rs @@ -77,6 +77,7 @@ pub enum BcaReqTypeV0 { Ping, SendTxs(Txs), Identities(ArrayVec<[PublicKey; 16]>), + CurrentUd, } // Request types helpers @@ -114,6 +115,7 @@ pub enum BcaRespTypeV0 { Pong, RejectedTxs(Vec<rejected_tx::RejectedTx>), Identities(ArrayVec<[Option<Identity>; 16]>), + CurrentUd(SourceAmount), } // Result and error