diff --git a/doc/release-notes.md b/doc/release-notes.md --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -9,3 +9,5 @@ mempool has been added to the `getmempoolinfo` RPC. - Added a new `getavalancheproofs` RPC to retrieve all avalanche proof IDs tracked by the node. + - Added a new field `immature_stake_amount` to `getavalancheinfo` to report + the total amount of stake that will mature within the next 2016 blocks. diff --git a/src/rpc/avalanche.cpp b/src/rpc/avalanche.cpp --- a/src/rpc/avalanche.cpp +++ b/src/rpc/avalanche.cpp @@ -707,6 +707,12 @@ Currency::get().ticker + " (including this node's local proof if " "applicable)."}, + {RPCResult::Type::STR_AMOUNT, "immature_stake_amount", + "The total staked amount over all the immature proofs " + "in " + + Currency::get().ticker + + " (including this node's local proof if " + "applicable)."}, {RPCResult::Type::NUM, "node_count", "The number of avalanche nodes we are connected to " "(including this node if a local proof is set)."}, @@ -786,6 +792,12 @@ connectedNodeCount += peer.node_count + isLocalProof; }); + Amount immatureStakes = Amount::zero(); + pm.getImmatureProofPool().forEachProof( + [&](const avalanche::ProofRef &proof) { + immatureStakes += proof->getStakedAmount(); + }); + network.pushKV("proof_count", proofCount); network.pushKV("connected_proof_count", connectedProofCount); network.pushKV("dangling_proof_count", @@ -803,6 +815,7 @@ network.pushKV("connected_stake_amount", connectedStakes); network.pushKV("dangling_stake_amount", totalStakes - connectedStakes); + network.pushKV("immature_stake_amount", immatureStakes); const uint64_t pendingNodes = pm.getPendingNodeCount(); network.pushKV("node_count", connectedNodeCount + pendingNodes); diff --git a/test/functional/abc_rpc_getavalancheinfo.py b/test/functional/abc_rpc_getavalancheinfo.py --- a/test/functional/abc_rpc_getavalancheinfo.py +++ b/test/functional/abc_rpc_getavalancheinfo.py @@ -64,6 +64,7 @@ "total_stake_amount": Decimal('0.00'), "connected_stake_amount": Decimal('0.00'), "dangling_stake_amount": Decimal('0.00'), + "immature_stake_amount": Decimal('0.00'), "node_count": 0, "connected_node_count": 0, "pending_node_count": 0, @@ -96,6 +97,7 @@ "total_stake_amount": Decimal('0.00'), "connected_stake_amount": Decimal('0.00'), "dangling_stake_amount": Decimal('0.00'), + "immature_stake_amount": Decimal('0.00'), "node_count": 0, "connected_node_count": 0, "pending_node_count": 0, @@ -130,6 +132,7 @@ "total_stake_amount": Decimal('0.00'), "connected_stake_amount": Decimal('0.00'), "dangling_stake_amount": Decimal('0.00'), + "immature_stake_amount": Decimal('0.00'), "node_count": 0, "connected_node_count": 0, "pending_node_count": 0, @@ -159,6 +162,7 @@ "total_stake_amount": coinbase_amount, "connected_stake_amount": coinbase_amount, "dangling_stake_amount": Decimal('0.00'), + "immature_stake_amount": Decimal('0.00'), "node_count": 1, "connected_node_count": 1, "pending_node_count": 0, @@ -230,6 +234,7 @@ "total_stake_amount": coinbase_amount * (N + 1), "connected_stake_amount": coinbase_amount * (N + 1), "dangling_stake_amount": Decimal('0.00'), + "immature_stake_amount": coinbase_amount, "node_count": N + 1, "connected_node_count": N + 1, "pending_node_count": 0, @@ -266,6 +271,7 @@ "total_stake_amount": coinbase_amount * (N + 1), "connected_stake_amount": coinbase_amount * (N + 1 - D), "dangling_stake_amount": coinbase_amount * D, + "immature_stake_amount": coinbase_amount, "node_count": N + 1 - D, "connected_node_count": N + 1 - D, "pending_node_count": 0, @@ -322,6 +328,7 @@ "total_stake_amount": coinbase_amount * (N + 2), "connected_stake_amount": coinbase_amount * (N + 1 - D), "dangling_stake_amount": coinbase_amount * (D + 1), + "immature_stake_amount": Decimal('0.00'), "node_count": N + 1 - D + P, "connected_node_count": N + 1 - D, "pending_node_count": P, @@ -392,6 +399,7 @@ "total_stake_amount": coinbase_amount * (N + 2), "connected_stake_amount": coinbase_amount, "dangling_stake_amount": coinbase_amount * (N + 1), + "immature_stake_amount": Decimal('0.00'), "node_count": 1, "connected_node_count": 1, "pending_node_count": 0,