 |
PRCYCoin
2.0.0.7rc1
P2P Digital Currency
|
Go to the documentation of this file.
6 #ifndef BITCOIN_MERKLEBLOCK_H
7 #define BITCOIN_MERKLEBLOCK_H
72 uint256 CalcHash(
int height,
unsigned int pos,
const std::vector<uint256>& vTxid);
75 void TraverseAndBuild(
int height,
unsigned int pos,
const std::vector<uint256>& vTxid,
const std::vector<bool>& vMatch);
81 uint256 TraverseAndExtract(
int height,
unsigned int pos,
unsigned int& nBitsUsed,
unsigned int& nHashUsed, std::vector<uint256>& vMatch);
87 template <
typename Stream,
typename Operation>
88 inline void SerializationOp(Stream& s, Operation ser_action,
int nType,
int nVersion)
92 std::vector<unsigned char> vBytes;
93 if (ser_action.ForRead()) {
96 us.
vBits.resize(vBytes.size() * 8);
97 for (
unsigned int p = 0; p < us.
vBits.size(); p++)
98 us.
vBits[p] = (vBytes[p / 8] & (1 << (p % 8))) != 0;
101 vBytes.resize((
vBits.size() + 7) / 8);
102 for (
unsigned int p = 0; p <
vBits.size(); p++)
103 vBytes[p / 8] |=
vBits[p] << (p % 8);
109 CPartialMerkleTree(
const std::vector<uint256>& vTxid,
const std::vector<bool>& vMatch);
147 template <
typename Stream,
typename Operation>
155 #endif // BITCOIN_MERKLEBLOCK_H
uint256 TraverseAndExtract(int height, unsigned int pos, unsigned int &nBitsUsed, unsigned int &nHashUsed, std::vector< uint256 > &vMatch)
recursive function that traverses tree nodes, consuming the bits and hashes produced by TraverseAndBu...
std::vector< bool > vBits
node-is-parent-of-matched-txid bits
Data structure that represents a partial merkle tree.
BloomFilter is a probabilistic filter which SPV clients provide so that we can filter the transaction...
Used to relay blocks as header + vector<merkle branch> to filtered nodes.
ADD_SERIALIZE_METHODS
serialization implementation
uint256 ExtractMatches(std::vector< uint256 > &vMatch)
extract the matching txid's represented by this partial merkle tree.
CBlockHeader header
Public only for unit testing.
uint256 CalcHash(int height, unsigned int pos, const std::vector< uint256 > &vTxid)
calculate the hash of a node in the merkle tree (at leaf level: the txid's themselves)
void TraverseAndBuild(int height, unsigned int pos, const std::vector< uint256 > &vTxid, const std::vector< bool > &vMatch)
recursive function that traverses tree nodes, storing the data as bits and hashes
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
256-bit unsigned big integer.
bool fBad
flag set when encountering invalid data
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
unsigned int nTransactions
the total number of transactions in the block
std::vector< std::pair< unsigned int, uint256 > > vMatchedTxn
Public only for unit testing and relay testing (not relayed)
CMerkleBlock(const CBlock &block, CBloomFilter &filter)
Create from a CBlock, filtering transactions according to filter Note that this will call IsRelevantA...
std::vector< uint256 > vHash
txids and internal hashes
unsigned int CalcTreeWidth(int height)
helper function to efficiently calculate the number of nodes at given height in the merkle tree