Drop unused GetType() from CSizeComputer
This commit is contained in:
parent
4e9a6f87b7
commit
da74db0940
17 changed files with 33 additions and 35 deletions
|
@ -162,7 +162,7 @@ ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& c
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogPrint(BCLog::CMPCTBLOCK, "Initialized PartiallyDownloadedBlock for block %s using a cmpctblock of size %lu\n", cmpctblock.header.GetHash().ToString(), GetSerializeSize(cmpctblock, SER_NETWORK, PROTOCOL_VERSION));
|
LogPrint(BCLog::CMPCTBLOCK, "Initialized PartiallyDownloadedBlock for block %s using a cmpctblock of size %lu\n", cmpctblock.header.GetHash().ToString(), GetSerializeSize(cmpctblock, PROTOCOL_VERSION));
|
||||||
|
|
||||||
return READ_STATUS_OK;
|
return READ_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -244,7 +244,7 @@ bool CCoinsViewCache::HaveInputs(const CTransaction& tx) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const size_t MIN_TRANSACTION_OUTPUT_WEIGHT = WITNESS_SCALE_FACTOR * ::GetSerializeSize(CTxOut(), SER_NETWORK, PROTOCOL_VERSION);
|
static const size_t MIN_TRANSACTION_OUTPUT_WEIGHT = WITNESS_SCALE_FACTOR * ::GetSerializeSize(CTxOut(), PROTOCOL_VERSION);
|
||||||
static const size_t MAX_OUTPUTS_PER_BLOCK = MAX_BLOCK_WEIGHT / MIN_TRANSACTION_OUTPUT_WEIGHT;
|
static const size_t MAX_OUTPUTS_PER_BLOCK = MAX_BLOCK_WEIGHT / MIN_TRANSACTION_OUTPUT_WEIGHT;
|
||||||
|
|
||||||
const Coin& AccessByTxid(const CCoinsViewCache& view, const uint256& txid)
|
const Coin& AccessByTxid(const CCoinsViewCache& view, const uint256& txid)
|
||||||
|
|
|
@ -164,7 +164,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, bool fChe
|
||||||
if (tx.vout.empty())
|
if (tx.vout.empty())
|
||||||
return state.DoS(10, false, REJECT_INVALID, "bad-txns-vout-empty");
|
return state.DoS(10, false, REJECT_INVALID, "bad-txns-vout-empty");
|
||||||
// Size limits (this doesn't take the witness into account, as that hasn't been checked for malleability)
|
// Size limits (this doesn't take the witness into account, as that hasn't been checked for malleability)
|
||||||
if (::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * WITNESS_SCALE_FACTOR > MAX_BLOCK_WEIGHT)
|
if (::GetSerializeSize(tx, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * WITNESS_SCALE_FACTOR > MAX_BLOCK_WEIGHT)
|
||||||
return state.DoS(100, false, REJECT_INVALID, "bad-txns-oversize");
|
return state.DoS(100, false, REJECT_INVALID, "bad-txns-oversize");
|
||||||
|
|
||||||
// Check for negative or overflow output values
|
// Check for negative or overflow output values
|
||||||
|
|
|
@ -95,16 +95,16 @@ public:
|
||||||
// weight = (stripped_size * 3) + total_size.
|
// weight = (stripped_size * 3) + total_size.
|
||||||
static inline int64_t GetTransactionWeight(const CTransaction& tx)
|
static inline int64_t GetTransactionWeight(const CTransaction& tx)
|
||||||
{
|
{
|
||||||
return ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * (WITNESS_SCALE_FACTOR - 1) + ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
|
return ::GetSerializeSize(tx, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * (WITNESS_SCALE_FACTOR - 1) + ::GetSerializeSize(tx, PROTOCOL_VERSION);
|
||||||
}
|
}
|
||||||
static inline int64_t GetBlockWeight(const CBlock& block)
|
static inline int64_t GetBlockWeight(const CBlock& block)
|
||||||
{
|
{
|
||||||
return ::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * (WITNESS_SCALE_FACTOR - 1) + ::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION);
|
return ::GetSerializeSize(block, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * (WITNESS_SCALE_FACTOR - 1) + ::GetSerializeSize(block, PROTOCOL_VERSION);
|
||||||
}
|
}
|
||||||
static inline int64_t GetTransactionInputWeight(const CTxIn& txin)
|
static inline int64_t GetTransactionInputWeight(const CTxIn& txin)
|
||||||
{
|
{
|
||||||
// scriptWitness size is added here because witnesses and txins are split up in segwit serialization.
|
// scriptWitness size is added here because witnesses and txins are split up in segwit serialization.
|
||||||
return ::GetSerializeSize(txin, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * (WITNESS_SCALE_FACTOR - 1) + ::GetSerializeSize(txin, SER_NETWORK, PROTOCOL_VERSION) + ::GetSerializeSize(txin.scriptWitness.stack, SER_NETWORK, PROTOCOL_VERSION);
|
return ::GetSerializeSize(txin, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * (WITNESS_SCALE_FACTOR - 1) + ::GetSerializeSize(txin, PROTOCOL_VERSION) + ::GetSerializeSize(txin.scriptWitness.stack, PROTOCOL_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // BITCOIN_CONSENSUS_VALIDATION_H
|
#endif // BITCOIN_CONSENSUS_VALIDATION_H
|
||||||
|
|
|
@ -181,7 +181,7 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
|
||||||
entry.pushKV("txid", tx.GetHash().GetHex());
|
entry.pushKV("txid", tx.GetHash().GetHex());
|
||||||
entry.pushKV("hash", tx.GetWitnessHash().GetHex());
|
entry.pushKV("hash", tx.GetWitnessHash().GetHex());
|
||||||
entry.pushKV("version", tx.nVersion);
|
entry.pushKV("version", tx.nVersion);
|
||||||
entry.pushKV("size", (int)::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION));
|
entry.pushKV("size", (int)::GetSerializeSize(tx, PROTOCOL_VERSION));
|
||||||
entry.pushKV("vsize", (GetTransactionWeight(tx) + WITNESS_SCALE_FACTOR - 1) / WITNESS_SCALE_FACTOR);
|
entry.pushKV("vsize", (GetTransactionWeight(tx) + WITNESS_SCALE_FACTOR - 1) / WITNESS_SCALE_FACTOR);
|
||||||
entry.pushKV("weight", GetTransactionWeight(tx));
|
entry.pushKV("weight", GetTransactionWeight(tx));
|
||||||
entry.pushKV("locktime", (int64_t)tx.nLockTime);
|
entry.pushKV("locktime", (int64_t)tx.nLockTime);
|
||||||
|
|
|
@ -250,7 +250,7 @@ bool TxIndex::WriteBlock(const CBlock& block, const CBlockIndex* pindex)
|
||||||
vPos.reserve(block.vtx.size());
|
vPos.reserve(block.vtx.size());
|
||||||
for (const auto& tx : block.vtx) {
|
for (const auto& tx : block.vtx) {
|
||||||
vPos.emplace_back(tx->GetHash(), pos);
|
vPos.emplace_back(tx->GetHash(), pos);
|
||||||
pos.nTxOffset += ::GetSerializeSize(*tx, SER_DISK, CLIENT_VERSION);
|
pos.nTxOffset += ::GetSerializeSize(*tx, CLIENT_VERSION);
|
||||||
}
|
}
|
||||||
return m_db->WriteTxs(vPos);
|
return m_db->WriteTxs(vPos);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ CAmount GetDustThreshold(const CTxOut& txout, const CFeeRate& dustRelayFeeIn)
|
||||||
if (txout.scriptPubKey.IsUnspendable())
|
if (txout.scriptPubKey.IsUnspendable())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
size_t nSize = GetSerializeSize(txout, SER_DISK, 0);
|
size_t nSize = GetSerializeSize(txout);
|
||||||
int witnessversion = 0;
|
int witnessversion = 0;
|
||||||
std::vector<unsigned char> witnessprogram;
|
std::vector<unsigned char> witnessprogram;
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ CAmount CTransaction::GetValueOut() const
|
||||||
|
|
||||||
unsigned int CTransaction::GetTotalSize() const
|
unsigned int CTransaction::GetTotalSize() const
|
||||||
{
|
{
|
||||||
return ::GetSerializeSize(*this, SER_NETWORK, PROTOCOL_VERSION);
|
return ::GetSerializeSize(*this, PROTOCOL_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CTransaction::ToString() const
|
std::string CTransaction::ToString() const
|
||||||
|
|
|
@ -121,8 +121,8 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx
|
||||||
if (chainActive.Contains(blockindex))
|
if (chainActive.Contains(blockindex))
|
||||||
confirmations = chainActive.Height() - blockindex->nHeight + 1;
|
confirmations = chainActive.Height() - blockindex->nHeight + 1;
|
||||||
result.pushKV("confirmations", confirmations);
|
result.pushKV("confirmations", confirmations);
|
||||||
result.pushKV("strippedsize", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS));
|
result.pushKV("strippedsize", (int)::GetSerializeSize(block, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS));
|
||||||
result.pushKV("size", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION));
|
result.pushKV("size", (int)::GetSerializeSize(block, PROTOCOL_VERSION));
|
||||||
result.pushKV("weight", (int)::GetBlockWeight(block));
|
result.pushKV("weight", (int)::GetBlockWeight(block));
|
||||||
result.pushKV("height", blockindex->nHeight);
|
result.pushKV("height", blockindex->nHeight);
|
||||||
result.pushKV("version", block.nVersion);
|
result.pushKV("version", block.nVersion);
|
||||||
|
@ -1831,7 +1831,7 @@ static UniValue getblockstats(const JSONRPCRequest& request)
|
||||||
if (loop_outputs) {
|
if (loop_outputs) {
|
||||||
for (const CTxOut& out : tx->vout) {
|
for (const CTxOut& out : tx->vout) {
|
||||||
tx_total_out += out.nValue;
|
tx_total_out += out.nValue;
|
||||||
utxo_size_inc += GetSerializeSize(out, SER_NETWORK, PROTOCOL_VERSION) + PER_UTXO_OVERHEAD;
|
utxo_size_inc += GetSerializeSize(out, PROTOCOL_VERSION) + PER_UTXO_OVERHEAD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1882,7 +1882,7 @@ static UniValue getblockstats(const JSONRPCRequest& request)
|
||||||
CTxOut prevoutput = tx_in->vout[in.prevout.n];
|
CTxOut prevoutput = tx_in->vout[in.prevout.n];
|
||||||
|
|
||||||
tx_total_in += prevoutput.nValue;
|
tx_total_in += prevoutput.nValue;
|
||||||
utxo_size_inc -= GetSerializeSize(prevoutput, SER_NETWORK, PROTOCOL_VERSION) + PER_UTXO_OVERHEAD;
|
utxo_size_inc -= GetSerializeSize(prevoutput, PROTOCOL_VERSION) + PER_UTXO_OVERHEAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAmount txfee = tx_total_in - tx_total_out;
|
CAmount txfee = tx_total_in - tx_total_out;
|
||||||
|
|
|
@ -88,7 +88,7 @@ static int verify_script(const unsigned char *scriptPubKey, unsigned int scriptP
|
||||||
CTransaction tx(deserialize, stream);
|
CTransaction tx(deserialize, stream);
|
||||||
if (nIn >= tx.vin.size())
|
if (nIn >= tx.vin.size())
|
||||||
return set_error(err, bitcoinconsensus_ERR_TX_INDEX);
|
return set_error(err, bitcoinconsensus_ERR_TX_INDEX);
|
||||||
if (GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION) != txToLen)
|
if (GetSerializeSize(tx, PROTOCOL_VERSION) != txToLen)
|
||||||
return set_error(err, bitcoinconsensus_ERR_TX_SIZE_MISMATCH);
|
return set_error(err, bitcoinconsensus_ERR_TX_SIZE_MISMATCH);
|
||||||
|
|
||||||
// Regardless of the verification result, the tx did not error.
|
// Regardless of the verification result, the tx did not error.
|
||||||
|
|
|
@ -901,10 +901,9 @@ class CSizeComputer
|
||||||
protected:
|
protected:
|
||||||
size_t nSize;
|
size_t nSize;
|
||||||
|
|
||||||
const int nType;
|
|
||||||
const int nVersion;
|
const int nVersion;
|
||||||
public:
|
public:
|
||||||
CSizeComputer(int nTypeIn, int nVersionIn) : nSize(0), nType(nTypeIn), nVersion(nVersionIn) {}
|
explicit CSizeComputer(int nVersionIn) : nSize(0), nVersion(nVersionIn) {}
|
||||||
|
|
||||||
void write(const char *psz, size_t _nSize)
|
void write(const char *psz, size_t _nSize)
|
||||||
{
|
{
|
||||||
|
@ -929,7 +928,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetVersion() const { return nVersion; }
|
int GetVersion() const { return nVersion; }
|
||||||
int GetType() const { return nType; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Stream>
|
template<typename Stream>
|
||||||
|
@ -980,15 +978,15 @@ inline void WriteCompactSize(CSizeComputer &s, uint64_t nSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
size_t GetSerializeSize(const T& t, int nType, int nVersion = 0)
|
size_t GetSerializeSize(const T& t, int nVersion = 0)
|
||||||
{
|
{
|
||||||
return (CSizeComputer(nType, nVersion) << t).size();
|
return (CSizeComputer(nVersion) << t).size();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename S, typename T>
|
template <typename S, typename T>
|
||||||
size_t GetSerializeSize(const S& s, const T& t)
|
size_t GetSerializeSize(const S& s, const T& t)
|
||||||
{
|
{
|
||||||
return (CSizeComputer(s.GetType(), s.GetVersion()) << t).size();
|
return (CSizeComputer(s.GetVersion()) << t).size();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename S, typename... T>
|
template <typename S, typename... T>
|
||||||
|
|
|
@ -139,7 +139,7 @@ static void TestPackageSelection(const CChainParams& chainparams, const CScript&
|
||||||
tx.vout[0].nValue = 5000000000LL - 1000 - 50000; // 0 fee
|
tx.vout[0].nValue = 5000000000LL - 1000 - 50000; // 0 fee
|
||||||
uint256 hashFreeTx = tx.GetHash();
|
uint256 hashFreeTx = tx.GetHash();
|
||||||
mempool.addUnchecked(entry.Fee(0).FromTx(tx));
|
mempool.addUnchecked(entry.Fee(0).FromTx(tx));
|
||||||
size_t freeTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
|
size_t freeTxSize = ::GetSerializeSize(tx, PROTOCOL_VERSION);
|
||||||
|
|
||||||
// Calculate a fee on child transaction that will put the package just
|
// Calculate a fee on child transaction that will put the package just
|
||||||
// below the block min tx fee (assuming 1 child tx of the same size).
|
// below the block min tx fee (assuming 1 child tx of the same size).
|
||||||
|
|
|
@ -182,13 +182,13 @@ BOOST_AUTO_TEST_CASE(varints)
|
||||||
CDataStream::size_type size = 0;
|
CDataStream::size_type size = 0;
|
||||||
for (int i = 0; i < 100000; i++) {
|
for (int i = 0; i < 100000; i++) {
|
||||||
ss << VARINT(i, VarIntMode::NONNEGATIVE_SIGNED);
|
ss << VARINT(i, VarIntMode::NONNEGATIVE_SIGNED);
|
||||||
size += ::GetSerializeSize(VARINT(i, VarIntMode::NONNEGATIVE_SIGNED), 0, 0);
|
size += ::GetSerializeSize(VARINT(i, VarIntMode::NONNEGATIVE_SIGNED), 0);
|
||||||
BOOST_CHECK(size == ss.size());
|
BOOST_CHECK(size == ss.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint64_t i = 0; i < 100000000000ULL; i += 999999937) {
|
for (uint64_t i = 0; i < 100000000000ULL; i += 999999937) {
|
||||||
ss << VARINT(i);
|
ss << VARINT(i);
|
||||||
size += ::GetSerializeSize(VARINT(i), 0, 0);
|
size += ::GetSerializeSize(VARINT(i), 0);
|
||||||
BOOST_CHECK(size == ss.size());
|
BOOST_CHECK(size == ss.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -184,8 +184,8 @@ BOOST_AUTO_TEST_CASE( methods ) // GetHex SetHex begin() end() size() GetLow64 G
|
||||||
BOOST_CHECK(OneL.begin() + 32 == OneL.end());
|
BOOST_CHECK(OneL.begin() + 32 == OneL.end());
|
||||||
BOOST_CHECK(MaxL.begin() + 32 == MaxL.end());
|
BOOST_CHECK(MaxL.begin() + 32 == MaxL.end());
|
||||||
BOOST_CHECK(TmpL.begin() + 32 == TmpL.end());
|
BOOST_CHECK(TmpL.begin() + 32 == TmpL.end());
|
||||||
BOOST_CHECK(GetSerializeSize(R1L, 0, PROTOCOL_VERSION) == 32);
|
BOOST_CHECK(GetSerializeSize(R1L, PROTOCOL_VERSION) == 32);
|
||||||
BOOST_CHECK(GetSerializeSize(ZeroL, 0, PROTOCOL_VERSION) == 32);
|
BOOST_CHECK(GetSerializeSize(ZeroL, PROTOCOL_VERSION) == 32);
|
||||||
|
|
||||||
CDataStream ss(0, PROTOCOL_VERSION);
|
CDataStream ss(0, PROTOCOL_VERSION);
|
||||||
ss << R1L;
|
ss << R1L;
|
||||||
|
@ -230,8 +230,8 @@ BOOST_AUTO_TEST_CASE( methods ) // GetHex SetHex begin() end() size() GetLow64 G
|
||||||
BOOST_CHECK(OneS.begin() + 20 == OneS.end());
|
BOOST_CHECK(OneS.begin() + 20 == OneS.end());
|
||||||
BOOST_CHECK(MaxS.begin() + 20 == MaxS.end());
|
BOOST_CHECK(MaxS.begin() + 20 == MaxS.end());
|
||||||
BOOST_CHECK(TmpS.begin() + 20 == TmpS.end());
|
BOOST_CHECK(TmpS.begin() + 20 == TmpS.end());
|
||||||
BOOST_CHECK(GetSerializeSize(R1S, 0, PROTOCOL_VERSION) == 20);
|
BOOST_CHECK(GetSerializeSize(R1S, PROTOCOL_VERSION) == 20);
|
||||||
BOOST_CHECK(GetSerializeSize(ZeroS, 0, PROTOCOL_VERSION) == 20);
|
BOOST_CHECK(GetSerializeSize(ZeroS, PROTOCOL_VERSION) == 20);
|
||||||
|
|
||||||
ss << R1S;
|
ss << R1S;
|
||||||
BOOST_CHECK(ss.str() == std::string(R1Array,R1Array+20));
|
BOOST_CHECK(ss.str() == std::string(R1Array,R1Array+20));
|
||||||
|
|
|
@ -61,7 +61,7 @@ public:
|
||||||
explicit TxInUndoDeserializer(Coin* coin) : txout(coin) {}
|
explicit TxInUndoDeserializer(Coin* coin) : txout(coin) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
static const size_t MIN_TRANSACTION_INPUT_WEIGHT = WITNESS_SCALE_FACTOR * ::GetSerializeSize(CTxIn(), SER_NETWORK, PROTOCOL_VERSION);
|
static const size_t MIN_TRANSACTION_INPUT_WEIGHT = WITNESS_SCALE_FACTOR * ::GetSerializeSize(CTxIn(), PROTOCOL_VERSION);
|
||||||
static const size_t MAX_INPUTS_PER_BLOCK = MAX_BLOCK_WEIGHT / MIN_TRANSACTION_INPUT_WEIGHT;
|
static const size_t MAX_INPUTS_PER_BLOCK = MAX_BLOCK_WEIGHT / MIN_TRANSACTION_INPUT_WEIGHT;
|
||||||
|
|
||||||
/** Undo information for a CTransaction */
|
/** Undo information for a CTransaction */
|
||||||
|
|
|
@ -584,7 +584,7 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
|
||||||
// Do not work on transactions that are too small.
|
// Do not work on transactions that are too small.
|
||||||
// A transaction with 1 segwit input and 1 P2WPHK output has non-witness size of 82 bytes.
|
// A transaction with 1 segwit input and 1 P2WPHK output has non-witness size of 82 bytes.
|
||||||
// Transactions smaller than this are not relayed to reduce unnecessary malloc overhead.
|
// Transactions smaller than this are not relayed to reduce unnecessary malloc overhead.
|
||||||
if (::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) < MIN_STANDARD_TX_NONWITNESS_SIZE)
|
if (::GetSerializeSize(tx, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) < MIN_STANDARD_TX_NONWITNESS_SIZE)
|
||||||
return state.DoS(0, false, REJECT_NONSTANDARD, "tx-size-small");
|
return state.DoS(0, false, REJECT_NONSTANDARD, "tx-size-small");
|
||||||
|
|
||||||
// Only accept nLockTime-using transactions that can be mined in the next
|
// Only accept nLockTime-using transactions that can be mined in the next
|
||||||
|
@ -1668,7 +1668,7 @@ static bool WriteUndoDataForBlock(const CBlockUndo& blockundo, CValidationState&
|
||||||
// Write undo information to disk
|
// Write undo information to disk
|
||||||
if (pindex->GetUndoPos().IsNull()) {
|
if (pindex->GetUndoPos().IsNull()) {
|
||||||
CDiskBlockPos _pos;
|
CDiskBlockPos _pos;
|
||||||
if (!FindUndoPos(state, pindex->nFile, _pos, ::GetSerializeSize(blockundo, SER_DISK, CLIENT_VERSION) + 40))
|
if (!FindUndoPos(state, pindex->nFile, _pos, ::GetSerializeSize(blockundo, CLIENT_VERSION) + 40))
|
||||||
return error("ConnectBlock(): FindUndoPos failed");
|
return error("ConnectBlock(): FindUndoPos failed");
|
||||||
if (!UndoWriteToDisk(blockundo, _pos, pindex->pprev->GetBlockHash(), chainparams.MessageStart()))
|
if (!UndoWriteToDisk(blockundo, _pos, pindex->pprev->GetBlockHash(), chainparams.MessageStart()))
|
||||||
return AbortNode(state, "Failed to write undo data");
|
return AbortNode(state, "Failed to write undo data");
|
||||||
|
@ -3119,7 +3119,7 @@ bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::P
|
||||||
// checks that use witness data may be performed here.
|
// checks that use witness data may be performed here.
|
||||||
|
|
||||||
// Size limits
|
// Size limits
|
||||||
if (block.vtx.empty() || block.vtx.size() * WITNESS_SCALE_FACTOR > MAX_BLOCK_WEIGHT || ::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * WITNESS_SCALE_FACTOR > MAX_BLOCK_WEIGHT)
|
if (block.vtx.empty() || block.vtx.size() * WITNESS_SCALE_FACTOR > MAX_BLOCK_WEIGHT || ::GetSerializeSize(block, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * WITNESS_SCALE_FACTOR > MAX_BLOCK_WEIGHT)
|
||||||
return state.DoS(100, false, REJECT_INVALID, "bad-blk-length", false, "size limits failed");
|
return state.DoS(100, false, REJECT_INVALID, "bad-blk-length", false, "size limits failed");
|
||||||
|
|
||||||
// First transaction must be coinbase, the rest must not be
|
// First transaction must be coinbase, the rest must not be
|
||||||
|
@ -3436,7 +3436,7 @@ bool ProcessNewBlockHeaders(const std::vector<CBlockHeader>& headers, CValidatio
|
||||||
|
|
||||||
/** Store block on disk. If dbp is non-nullptr, the file is known to already reside on disk */
|
/** Store block on disk. If dbp is non-nullptr, the file is known to already reside on disk */
|
||||||
static CDiskBlockPos SaveBlockToDisk(const CBlock& block, int nHeight, const CChainParams& chainparams, const CDiskBlockPos* dbp) {
|
static CDiskBlockPos SaveBlockToDisk(const CBlock& block, int nHeight, const CChainParams& chainparams, const CDiskBlockPos* dbp) {
|
||||||
unsigned int nBlockSize = ::GetSerializeSize(block, SER_DISK, CLIENT_VERSION);
|
unsigned int nBlockSize = ::GetSerializeSize(block, CLIENT_VERSION);
|
||||||
CDiskBlockPos blockPos;
|
CDiskBlockPos blockPos;
|
||||||
if (dbp != nullptr)
|
if (dbp != nullptr)
|
||||||
blockPos = *dbp;
|
blockPos = *dbp;
|
||||||
|
|
|
@ -2763,7 +2763,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
|
||||||
scriptChange = GetScriptForDestination(GetDestinationForKey(vchPubKey, change_type));
|
scriptChange = GetScriptForDestination(GetDestinationForKey(vchPubKey, change_type));
|
||||||
}
|
}
|
||||||
CTxOut change_prototype_txout(0, scriptChange);
|
CTxOut change_prototype_txout(0, scriptChange);
|
||||||
coin_selection_params.change_output_size = GetSerializeSize(change_prototype_txout, SER_DISK, 0);
|
coin_selection_params.change_output_size = GetSerializeSize(change_prototype_txout);
|
||||||
|
|
||||||
CFeeRate discard_rate = GetDiscardRate(*this, ::feeEstimator);
|
CFeeRate discard_rate = GetDiscardRate(*this, ::feeEstimator);
|
||||||
|
|
||||||
|
@ -2807,7 +2807,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Include the fee cost for outputs. Note this is only used for BnB right now
|
// Include the fee cost for outputs. Note this is only used for BnB right now
|
||||||
coin_selection_params.tx_noinputs_size += ::GetSerializeSize(txout, SER_NETWORK, PROTOCOL_VERSION);
|
coin_selection_params.tx_noinputs_size += ::GetSerializeSize(txout, PROTOCOL_VERSION);
|
||||||
|
|
||||||
if (IsDust(txout, ::dustRelayFee))
|
if (IsDust(txout, ::dustRelayFee))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue