Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/proofbuilder.cpp
Show All 19 Lines | SignedStake ProofBuilder::StakeSigner::sign(const ProofId &proofid) { | ||||
} else { | } else { | ||||
sig.fill(0); | sig.fill(0); | ||||
} | } | ||||
return SignedStake(std::move(stake), std::move(sig)); | return SignedStake(std::move(stake), std::move(sig)); | ||||
} | } | ||||
bool ProofBuilder::addUTXO(COutPoint utxo, Amount amount, uint32_t height, | bool ProofBuilder::addUTXO(COutPoint utxo, Amount amount, uint32_t height, | ||||
CKey key) { | bool is_coinbase, CKey key) { | ||||
if (!key.IsValid()) { | if (!key.IsValid()) { | ||||
return false; | return false; | ||||
} | } | ||||
stakes.emplace_back(Stake(std::move(utxo), amount, height, key.GetPubKey()), | stakes.emplace_back( | ||||
Stake(std::move(utxo), amount, height, is_coinbase, key.GetPubKey()), | |||||
std::move(key)); | std::move(key)); | ||||
return true; | return true; | ||||
} | } | ||||
Proof ProofBuilder::build() { | Proof ProofBuilder::build() { | ||||
const ProofId proofid = getProofId(); | const ProofId proofid = getProofId(); | ||||
std::vector<SignedStake> signedStakes; | std::vector<SignedStake> signedStakes; | ||||
signedStakes.reserve(stakes.size()); | signedStakes.reserve(stakes.size()); | ||||
Show All 22 Lines | |||||
} | } | ||||
Proof ProofBuilder::buildRandom(uint32_t score) { | Proof ProofBuilder::buildRandom(uint32_t score) { | ||||
CKey key; | CKey key; | ||||
key.MakeNewKey(true); | key.MakeNewKey(true); | ||||
ProofBuilder pb(0, std::numeric_limits<uint32_t>::max(), CPubKey()); | ProofBuilder pb(0, std::numeric_limits<uint32_t>::max(), CPubKey()); | ||||
pb.addUTXO(COutPoint(TxId(GetRandHash()), 0), (int64_t(score) * COIN) / 100, | pb.addUTXO(COutPoint(TxId(GetRandHash()), 0), (int64_t(score) * COIN) / 100, | ||||
0, std::move(key)); | 0, false, std::move(key)); | ||||
return pb.build(); | return pb.build(); | ||||
} | } | ||||
} // namespace avalanche | } // namespace avalanche |