aboutsummaryrefslogtreecommitdiff
path: root/src/merkleblock.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter@wuille.net>2020-03-11 09:34:20 -0700
committerPieter Wuille <pieter@wuille.net>2020-03-30 16:09:51 -0700
commit73747afbbeb013669faf4c4d2c0903cec4526fb0 (patch)
tree615759d2ff94c7c3ec5b1ba69797e1e499d4d7ce /src/merkleblock.cpp
parentd06fedd1bc26bf5bf2b203d4445aeaebccca780e (diff)
Convert merkleblock to new serialization
Diffstat (limited to 'src/merkleblock.cpp')
-rw-r--r--src/merkleblock.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/merkleblock.cpp b/src/merkleblock.cpp
index 4ac6219886..8072b12119 100644
--- a/src/merkleblock.cpp
+++ b/src/merkleblock.cpp
@@ -9,6 +9,24 @@
#include <consensus/consensus.h>
+std::vector<unsigned char> BitsToBytes(const std::vector<bool>& bits)
+{
+ std::vector<unsigned char> ret((bits.size() + 7) / 8);
+ for (unsigned int p = 0; p < bits.size(); p++) {
+ ret[p / 8] |= bits[p] << (p % 8);
+ }
+ return ret;
+}
+
+std::vector<bool> BytesToBits(const std::vector<unsigned char>& bytes)
+{
+ std::vector<bool> ret(bytes.size() * 8);
+ for (unsigned int p = 0; p < ret.size(); p++) {
+ ret[p] = (bytes[p / 8] & (1 << (p % 8))) != 0;
+ }
+ return ret;
+}
+
CMerkleBlock::CMerkleBlock(const CBlock& block, CBloomFilter* filter, const std::set<uint256>* txids)
{
header = block.GetBlockHeader();