Changeset View
Changeset View
Standalone View
Standalone View
src/utxocommit.h
// Copyright (c) 2017 The Bitcoin developers | // Copyright (c) 2017 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_UTXOCOMMIT_H | #ifndef BITCOIN_UTXOCOMMIT_H | ||||
#define BITCOIN_UTXOCOMMIT_H | #define BITCOIN_UTXOCOMMIT_H | ||||
#include "coins.h" | #include "coins.h" | ||||
#include "hash.h" | #include "hash.h" | ||||
#include "secp256k1/include/secp256k1_multiset.h" | #include "secp256k1/include/secp256k1_multiset.h" | ||||
#include "streams.h" | #include "streams.h" | ||||
#include <vector> | #include <vector> | ||||
class Coin; | class Coin; | ||||
class CCoinsViewCursor; | |||||
/* A Utxo Commitment | /* A Utxo Commitment | ||||
* | * | ||||
* This is maintained as 96-byte multiset value that uniquely defines a UTXO set | * This is maintained as 96-byte multiset value that uniquely defines a UTXO set | ||||
* | * | ||||
* It wraps the secp256k1 multiset | * It wraps the secp256k1 multiset | ||||
* | * | ||||
* Note that a CUtxoCommit allows "negative sets". That is | * Note that a CUtxoCommit allows "negative sets". That is | ||||
Show All 19 Lines | public: | ||||
// Adds a TXO from multiset | // Adds a TXO from multiset | ||||
void Add(const COutPoint &out, const Coin &element); | void Add(const COutPoint &out, const Coin &element); | ||||
// Removes a TXO from multiset | // Removes a TXO from multiset | ||||
void Remove(const COutPoint &out, const Coin &element); | void Remove(const COutPoint &out, const Coin &element); | ||||
uint256 GetHash() const; | uint256 GetHash() const; | ||||
// Initializes from an existing UTXO set | |||||
bool AddCoinView(CCoinsViewCursor *cursor); | |||||
// Comparison | // Comparison | ||||
friend bool operator==(const CUtxoCommit &a, const CUtxoCommit &b) { | friend bool operator==(const CUtxoCommit &a, const CUtxoCommit &b) { | ||||
return a.GetHash() == b.GetHash(); | return a.GetHash() == b.GetHash(); | ||||
} | } | ||||
friend bool operator!=(const CUtxoCommit &a, const CUtxoCommit &b) { | friend bool operator!=(const CUtxoCommit &a, const CUtxoCommit &b) { | ||||
return a.GetHash() != b.GetHash(); | return a.GetHash() != b.GetHash(); | ||||
} | } | ||||
~CUtxoCommit(); | ~CUtxoCommit(); | ||||
}; | }; | ||||
#endif // MULTISET_H | #endif // MULTISET_H |