From 36dc6e514fa5210d35baf219a62e126c45e980d5 Mon Sep 17 00:00:00 2001 From: Mathieu Baudet Date: Mon, 15 Nov 2021 17:35:08 -0800 Subject: [PATCH] [consensus] also expose which account ids have been locked so far --- fastpay_core/src/authority.rs | 1 + fastpay_core/src/messages.rs | 3 ++- fastpay_core/tests/staged/fastpay.yaml | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/fastpay_core/src/authority.rs b/fastpay_core/src/authority.rs index a8b5009..1016824 100644 --- a/fastpay_core/src/authority.rs +++ b/fastpay_core/src/authority.rs @@ -368,6 +368,7 @@ impl Authority for AuthorityState { .get_mut(&instance_id) .ok_or(FastPayError::UnknownConsensusInstance(instance_id))?; let info = ConsensusInfoResponse { + locked_accounts: instance.locked_accounts.clone(), proposed: instance.proposed.clone(), locked: instance.locked.clone(), received: instance.received.clone(), diff --git a/fastpay_core/src/messages.rs b/fastpay_core/src/messages.rs index 3b24ff7..1576c19 100644 --- a/fastpay_core/src/messages.rs +++ b/fastpay_core/src/messages.rs @@ -8,7 +8,7 @@ use super::{base_types::*, committee::Committee, error::FastPayError}; mod messages_tests; use serde::{Deserialize, Serialize}; -use std::collections::HashSet; +use std::collections::{BTreeMap, HashSet}; /// A message sent from the smart contract on the primary chain. #[derive(Eq, PartialEq, Clone, Debug, Serialize, Deserialize)] @@ -208,6 +208,7 @@ pub enum ConsensusOrder { #[derive(Clone, Debug, Serialize, Deserialize)] #[cfg_attr(test, derive(Eq, PartialEq))] pub struct ConsensusInfoResponse { + pub locked_accounts: BTreeMap, pub proposed: Option, pub locked: Option, pub received: Certificate, diff --git a/fastpay_core/tests/staged/fastpay.yaml b/fastpay_core/tests/staged/fastpay.yaml index 09cd189..87fd4a1 100644 --- a/fastpay_core/tests/staged/fastpay.yaml +++ b/fastpay_core/tests/staged/fastpay.yaml @@ -99,6 +99,12 @@ ConsensusDecision: Confirm: UNIT ConsensusInfoResponse: STRUCT: + - locked_accounts: + MAP: + KEY: + TYPENAME: AccountId + VALUE: + TYPENAME: PublicKeyBytes - proposed: OPTION: TYPENAME: ConsensusProposal