Changeset View
Changeset View
Standalone View
Standalone View
src/merkleblock.cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core 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. | ||||
#include <merkleblock.h> | #include <merkleblock.h> | ||||
#include <consensus/consensus.h> | #include <consensus/consensus.h> | ||||
#include <hash.h> | #include <hash.h> | ||||
std::vector<uint8_t> BitsToBytes(const std::vector<bool> &bits) { | |||||
std::vector<uint8_t> 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<uint8_t> &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, | CMerkleBlock::CMerkleBlock(const CBlock &block, CBloomFilter *filter, | ||||
const std::set<TxId> *txids) { | const std::set<TxId> *txids) { | ||||
header = block.GetBlockHeader(); | header = block.GetBlockHeader(); | ||||
std::vector<bool> vMatch; | std::vector<bool> vMatch; | ||||
std::vector<uint256> vHashes; | std::vector<uint256> vHashes; | ||||
vMatch.reserve(block.vtx.size()); | vMatch.reserve(block.vtx.size()); | ||||
▲ Show 20 Lines • Show All 197 Lines • Show Last 20 Lines |