Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/proof.h
// Copyright (c) 2020 The Bitcoin developers | // Copyright (c) 2020 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#ifndef BITCOIN_AVALANCHE_PROOF_H | #ifndef BITCOIN_AVALANCHE_PROOF_H | ||||
#define BITCOIN_AVALANCHE_PROOF_H | #define BITCOIN_AVALANCHE_PROOF_H | ||||
#include <amount.h> | #include <amount.h> | ||||
#include <avalanche/proofid.h> | #include <avalanche/proofid.h> | ||||
#include <key.h> | #include <key.h> | ||||
#include <primitives/transaction.h> | #include <primitives/transaction.h> | ||||
#include <pubkey.h> | #include <pubkey.h> | ||||
#include <rcu.h> | #include <rcu.h> | ||||
#include <serialize.h> | #include <serialize.h> | ||||
#include <validation.h> // For ChainstateManager and cs_main | |||||
#include <array> | #include <array> | ||||
#include <cstdint> | #include <cstdint> | ||||
#include <optional> | #include <optional> | ||||
#include <vector> | #include <vector> | ||||
class ArgsManager; | class ArgsManager; | ||||
class CCoinsView; | |||||
struct bilingual_str; | struct bilingual_str; | ||||
/** | /** | ||||
* How many UTXOs can be used for a single proof. | * How many UTXOs can be used for a single proof. | ||||
*/ | */ | ||||
static constexpr int AVALANCHE_MAX_PROOF_STAKES = 1000; | static constexpr int AVALANCHE_MAX_PROOF_STAKES = 1000; | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | public: | ||||
const LimitedProofId &getLimitedId() const { return limitedProofId; } | const LimitedProofId &getLimitedId() const { return limitedProofId; } | ||||
const StakeCommitment getStakeCommitment() const { | const StakeCommitment getStakeCommitment() const { | ||||
return StakeCommitment(proofid, expirationTime, master); | return StakeCommitment(proofid, expirationTime, master); | ||||
}; | }; | ||||
uint32_t getScore() const { return score; } | uint32_t getScore() const { return score; } | ||||
Amount getStakedAmount() const; | Amount getStakedAmount() const; | ||||
bool verify(ProofValidationState &state) const; | bool verify(ProofValidationState &state) const; | ||||
bool verify(ProofValidationState &state, const CCoinsView &view) const; | bool verify(ProofValidationState &state, | ||||
const ChainstateManager &chainman) const | |||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | |||||
}; | }; | ||||
using ProofRef = RCUPtr<const Proof>; | using ProofRef = RCUPtr<const Proof>; | ||||
class SaltedProofHasher : private SaltedUint256Hasher { | class SaltedProofHasher : private SaltedUint256Hasher { | ||||
public: | public: | ||||
SaltedProofHasher() : SaltedUint256Hasher() {} | SaltedProofHasher() : SaltedUint256Hasher() {} | ||||
size_t operator()(const ProofRef &proof) const { | size_t operator()(const ProofRef &proof) const { | ||||
return hash(proof->getId()); | return hash(proof->getId()); | ||||
} | } | ||||
}; | }; | ||||
} // namespace avalanche | } // namespace avalanche | ||||
#endif // BITCOIN_AVALANCHE_PROOF_H | #endif // BITCOIN_AVALANCHE_PROOF_H |