Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/proofid.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_PROOFID_H | #ifndef BITCOIN_AVALANCHE_PROOFID_H | ||||
#define BITCOIN_AVALANCHE_PROOFID_H | #define BITCOIN_AVALANCHE_PROOFID_H | ||||
#include <salteduint256hasher.h> | #include <salteduint256hasher.h> | ||||
#include <uint256.h> | #include <uint256.h> | ||||
#include <string> | #include <string> | ||||
class CPubKey; | |||||
namespace avalanche { | namespace avalanche { | ||||
struct LimitedProofId : public uint256 { | struct ProofId : public uint256 { | ||||
explicit LimitedProofId() : uint256() {} | explicit ProofId() : uint256() {} | ||||
explicit LimitedProofId(const uint256 &b) : uint256(b) {} | explicit ProofId(const uint256 &b) : uint256(b) {} | ||||
static LimitedProofId fromHex(const std::string &str) { | static ProofId fromHex(const std::string &str) { | ||||
LimitedProofId r; | ProofId r; | ||||
r.SetHex(str); | r.SetHex(str); | ||||
return r; | return r; | ||||
} | } | ||||
}; | }; | ||||
struct ProofId : public uint256 { | struct LimitedProofId : public uint256 { | ||||
explicit ProofId() : uint256() {} | explicit LimitedProofId() : uint256() {} | ||||
explicit ProofId(const uint256 &b) : uint256(b) {} | explicit LimitedProofId(const uint256 &b) : uint256(b) {} | ||||
static ProofId fromHex(const std::string &str) { | static LimitedProofId fromHex(const std::string &str) { | ||||
ProofId r; | LimitedProofId r; | ||||
r.SetHex(str); | r.SetHex(str); | ||||
return r; | return r; | ||||
} | } | ||||
ProofId computeProofId(const CPubKey &proofMaster) const; | |||||
}; | }; | ||||
class SaltedProofIdHasher : private SaltedUint256Hasher { | class SaltedProofIdHasher : private SaltedUint256Hasher { | ||||
public: | public: | ||||
SaltedProofIdHasher() : SaltedUint256Hasher() {} | SaltedProofIdHasher() : SaltedUint256Hasher() {} | ||||
size_t operator()(const ProofId &proofid) const { return hash(proofid); } | size_t operator()(const ProofId &proofid) const { return hash(proofid); } | ||||
}; | }; | ||||
} // namespace avalanche | } // namespace avalanche | ||||
#endif // BITCOIN_AVALANCHE_PROOFID_H | #endif // BITCOIN_AVALANCHE_PROOFID_H |