Changeset View
Changeset View
Standalone View
Standalone View
src/blockencodings.cpp
// Copyright (c) 2016 The Bitcoin Core developers | // Copyright (c) 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 "blockencodings.h" | #include "blockencodings.h" | ||||
#include "chainparams.h" | #include "chainparams.h" | ||||
#include "config.h" | #include "config.h" | ||||
#include "consensus/consensus.h" | #include "consensus/consensus.h" | ||||
#include "consensus/validation.h" | #include "consensus/validation.h" | ||||
#include "hash.h" | #include "hash.h" | ||||
#include "random.h" | #include "random.h" | ||||
#include "rwcollection.h" | |||||
#include "streams.h" | #include "streams.h" | ||||
#include "txmempool.h" | #include "txmempool.h" | ||||
#include "util.h" | #include "util.h" | ||||
#include "validation.h" | #include "validation.h" | ||||
#include <unordered_map> | #include <unordered_map> | ||||
CBlockHeaderAndShortTxIDs::CBlockHeaderAndShortTxIDs(const CBlock &block) | CBlockHeaderAndShortTxIDs::CBlockHeaderAndShortTxIDs(const CBlock &block) | ||||
Show All 23 Lines | |||||
uint64_t CBlockHeaderAndShortTxIDs::GetShortID(const uint256 &txhash) const { | uint64_t CBlockHeaderAndShortTxIDs::GetShortID(const uint256 &txhash) const { | ||||
static_assert(SHORTTXIDS_LENGTH == 6, | static_assert(SHORTTXIDS_LENGTH == 6, | ||||
"shorttxids calculation assumes 6-byte shorttxids"); | "shorttxids calculation assumes 6-byte shorttxids"); | ||||
return SipHashUint256(shorttxidk0, shorttxidk1, txhash) & 0xffffffffffffL; | return SipHashUint256(shorttxidk0, shorttxidk1, txhash) & 0xffffffffffffL; | ||||
} | } | ||||
ReadStatus PartiallyDownloadedBlock::InitData( | ReadStatus PartiallyDownloadedBlock::InitData( | ||||
const CBlockHeaderAndShortTxIDs &cmpctblock, | const CBlockHeaderAndShortTxIDs &cmpctblock, | ||||
const std::vector<std::pair<uint256, CTransactionRef>> &extra_txns) { | const RWCollection<std::vector<std::pair<uint256, CTransactionRef>>>:: | ||||
ReadView extra_txns) { | |||||
if (cmpctblock.header.IsNull() || | if (cmpctblock.header.IsNull() || | ||||
(cmpctblock.shorttxids.empty() && cmpctblock.prefilledtxn.empty())) { | (cmpctblock.shorttxids.empty() && cmpctblock.prefilledtxn.empty())) { | ||||
return READ_STATUS_INVALID; | return READ_STATUS_INVALID; | ||||
} | } | ||||
if (cmpctblock.shorttxids.size() + cmpctblock.prefilledtxn.size() > | if (cmpctblock.shorttxids.size() + cmpctblock.prefilledtxn.size() > | ||||
config->GetMaxBlockSize() / MIN_TRANSACTION_SIZE) { | config->GetMaxBlockSize() / MIN_TRANSACTION_SIZE) { | ||||
return READ_STATUS_INVALID; | return READ_STATUS_INVALID; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 210 Lines • Show Last 20 Lines |