Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/proofpool.h
- This file was added.
// Copyright (c) 2021 The Bitcoin developers | |||||
// Distributed under the MIT software license, see the accompanying | |||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | |||||
#ifndef BITCOIN_AVALANCHE_PROOFPOOL_H | |||||
#define BITCOIN_AVALANCHE_PROOFPOOL_H | |||||
#include <avalanche/proof.h> | |||||
#include <avalanche/proofcomparator.h> | |||||
#include <coins.h> // For SaltedOutpointHasher | |||||
#include <primitives/transaction.h> // For COutPoint | |||||
#include <set> | |||||
#include <unordered_map> | |||||
namespace avalanche { | |||||
/** | |||||
* Store the proofs indexed by utxo, sorted using the conflicting proof | |||||
* comparator. | |||||
* | |||||
* TODO Implement the CCoinsView interface and use it to determine if a coin is | |||||
* locked due to staking. | |||||
*/ | |||||
class ProofPool { | |||||
size_t maxProofsPerUtxo; | |||||
using UtxoMap = | |||||
deadalnix: This isn't a map of utxo, this is a map from utxo to proofs. So it is a map of proofs, but… | |||||
std::unordered_map<COutPoint, | |||||
std::set<ProofRef, ConflictingProofComparator>, | |||||
SaltedOutpointHasher>; | |||||
UtxoMap utxos; | |||||
public: | |||||
ProofPool(size_t maxProofsPerUtxoIn = 2) | |||||
deadalnixUnsubmitted Not Done Inline ActionsDo we really want to keep more than 1? And if the size is 2, do w really want to crate all these sets? Just store two pointers in there, no? deadalnix: Do we really want to keep more than 1? And if the size is 2, do w really want to crate all… | |||||
: maxProofsPerUtxo(maxProofsPerUtxoIn) {} | |||||
bool addProof(const ProofRef &proof, std::set<ProofRef> &shifted); | |||||
deadalnixUnsubmitted Not Done Inline Actionsshifted? deadalnix: shifted? | |||||
bool removeProof(const ProofRef &proof); | |||||
template <typename Callable> | |||||
bool forUtxo(const COutPoint &outpoint, Callable fun) const { | |||||
auto it = utxos.find(outpoint); | |||||
return it != utxos.end() && fun(it->second); | |||||
} | |||||
}; | |||||
} // namespace avalanche | |||||
#endif // BITCOIN_AVALANCHE_PROOFPOOL_H |
This isn't a map of utxo, this is a map from utxo to proofs. So it is a map of proofs, but considering this is in the proof pool, this isn't super informative.