Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14864871
D17716.id52897.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D17716.id52897.diff
View Options
diff --git a/src/avalanche/peermanager.h b/src/avalanche/peermanager.h
--- a/src/avalanche/peermanager.h
+++ b/src/avalanche/peermanager.h
@@ -509,6 +509,7 @@
* Deterministically select a list of payout scripts based on the proof set
* and the previous block hash.
*/
+ CScript pinnedStakeWinner;
bool selectStakingRewardWinner(
const CBlockIndex *pprev,
std::vector<std::pair<ProofId, CScript>> &winners);
diff --git a/src/avalanche/peermanager.cpp b/src/avalanche/peermanager.cpp
--- a/src/avalanche/peermanager.cpp
+++ b/src/avalanche/peermanager.cpp
@@ -1000,6 +1000,11 @@
return false;
}
+ if (pinnedStakeWinner != CScript()) {
+ winners.push_back({ProofId(), pinnedStakeWinner});
+ return true;
+ }
+
// Don't select proofs that have not been known for long enough, i.e. at
// least since twice the dangling proof cleanup timeout before the last
// block time, so we're sure to not account for proofs more recent than the
diff --git a/src/rpc/avalanche.cpp b/src/rpc/avalanche.cpp
--- a/src/rpc/avalanche.cpp
+++ b/src/rpc/avalanche.cpp
@@ -1232,6 +1232,32 @@
};
}
+static RPCHelpMan pinstakingreward() {
+ return RPCHelpMan{
+ "pinstakingreward",
+ "Pin the staking reward for all future blocks\n",
+ {
+ {"payoutscript", RPCArg::Type::STR_HEX, RPCArg::Optional::NO,
+ "The payout script for the staking reward, hex encoded."},
+ },
+ RPCResult{RPCResult::Type::BOOL, "success",
+ "Whether the payout script was set or not"},
+ RPCExamples{HelpExampleRpc("pinstakingreward", "<payout script>")},
+ [&](const RPCHelpMan &self, const Config &config,
+ const JSONRPCRequest &request) -> UniValue {
+ const NodeContext &node = EnsureAnyNodeContext(request.context);
+ avalanche::Processor &avalanche = EnsureAvalanche(node);
+
+ const std::vector<uint8_t> data =
+ ParseHex(request.params[0].get_str());
+ avalanche.withPeerManager([data](avalanche::PeerManager &pm) {
+ pm.pinnedStakeWinner = CScript(data.begin(), data.end());
+ return true;
+ });
+ return true;
+ }};
+}
+
static RPCHelpMan getremoteproofs() {
return RPCHelpMan{
"getremoteproofs",
@@ -1888,6 +1914,7 @@
{ "avalanche", getavalancheproofs, },
{ "avalanche", getstakingreward, },
{ "hidden", hasstakingreward, },
+ { "avalanche", pinstakingreward, },
{ "avalanche", setstakingreward, },
{ "avalanche", getremoteproofs, },
{ "avalanche", getrawavalancheproof, },
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, May 20, 22:56 (4 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5866107
Default Alt Text
D17716.id52897.diff (2 KB)
Attached To
D17716: [TESTNET ONLY] Override staking rewards using rpc
Event Timeline
Log In to Comment