fixed blockfilter_index_tests
This commit is contained in:
parent
cc037fafc4
commit
13a737de71
3 changed files with 15 additions and 9 deletions
|
@ -331,7 +331,7 @@ public:
|
|||
// FIXME: update heights and add activation tests
|
||||
consensus.BIP65Height = 1351; // BIP65 activated on regtest (Used in rpc activation tests)
|
||||
consensus.BIP66Height = 1251; // BIP66 activated on regtest (Used in rpc activation tests)
|
||||
consensus.CSVHeight = 432; // CSV activated on regtest (Used in rpc activation tests)
|
||||
consensus.CSVHeight = 0; // CSV activated on regtest (Used in rpc activation tests)
|
||||
consensus.SegwitHeight = 150; // SEGWIT is always activated on regtest unless overridden
|
||||
consensus.MinBIP9WarningHeight = 294;
|
||||
consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
|
|
|
@ -60,7 +60,10 @@ BlockFilterIndex::BlockFilterIndex(BlockFilterType filter_type,
|
|||
|
||||
bool BlockFilterIndex::Init()
|
||||
{
|
||||
m_db->ReadFilePos(m_next_filter_pos);
|
||||
if (!m_db->ReadFilePos(m_next_filter_pos)) {
|
||||
m_next_filter_pos.nFile = 0;
|
||||
m_next_filter_pos.nPos = 0;
|
||||
}
|
||||
return BaseIndex::Init();
|
||||
}
|
||||
|
||||
|
@ -175,7 +178,8 @@ bool BlockFilterIndex::WriteBlock(const CBlock& block, const CBlockIndex* pindex
|
|||
BlockFilter filter(m_filter_type, block, block_undo);
|
||||
|
||||
size_t bytes_written = WriteFilterToDisk(m_next_filter_pos, filter);
|
||||
if (bytes_written == 0) return false;
|
||||
if (bytes_written == 0)
|
||||
return false;
|
||||
|
||||
(*m_db) << "INSERT INTO block VALUES(?, ?, ?, ?, ?, ?)"
|
||||
<< pindex->nHeight
|
||||
|
@ -185,7 +189,7 @@ bool BlockFilterIndex::WriteBlock(const CBlock& block, const CBlockIndex* pindex
|
|||
<< m_next_filter_pos.nFile
|
||||
<< m_next_filter_pos.nPos;
|
||||
|
||||
if (!(m_db->rows_modified() > 0)) {
|
||||
if (m_db->rows_modified() <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -193,10 +197,11 @@ bool BlockFilterIndex::WriteBlock(const CBlock& block, const CBlockIndex* pindex
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool CopyHeightIndexToHashIndex(sqlite::database& db,
|
||||
int start_height, int stop_height)
|
||||
static bool CopyHeightIndexToHashIndex(sqlite::database& db, int start_height, int stop_height)
|
||||
{
|
||||
db << "UPDATE block SET height = NULL WHERE height >= ? and height <= ?"
|
||||
if (start_height > stop_height)
|
||||
return true;
|
||||
db << "UPDATE block SET height = NULL WHERE height BETWEEN ? AND ?"
|
||||
<< start_height << stop_height;
|
||||
return db.rows_modified() > 0;
|
||||
}
|
||||
|
|
|
@ -76,10 +76,11 @@ static CBlock CreateBlock(const CBlockIndex* prev,
|
|||
std::unique_ptr<CBlockTemplate> pblocktemplate = BlockAssembler(chainparams).CreateNewBlock(scriptPubKey);
|
||||
CBlock& block = pblocktemplate->block;
|
||||
block.hashPrevBlock = prev->GetBlockHash();
|
||||
block.hashClaimTrie = uint256S("0x0000000000000000000000000000000000000000000000000000000000000001");
|
||||
block.nTime = prev->nTime + 1;
|
||||
|
||||
// Replace mempool-selected txns with just coinbase plus passed-in txns:
|
||||
block.vtx.resize(1);
|
||||
block.vtx.resize(1); // coinbase TXN
|
||||
for (const CMutableTransaction& tx : txns) {
|
||||
block.vtx.push_back(MakeTransactionRef(tx));
|
||||
}
|
||||
|
@ -87,7 +88,7 @@ static CBlock CreateBlock(const CBlockIndex* prev,
|
|||
unsigned int extraNonce = 0;
|
||||
IncrementExtraNonce(&block, prev, extraNonce);
|
||||
|
||||
while (!CheckProofOfWork(block.GetHash(), block.nBits, chainparams.GetConsensus())) ++block.nNonce;
|
||||
while (!CheckProofOfWork(block.GetPoWHash(), block.nBits, chainparams.GetConsensus())) ++block.nNonce;
|
||||
|
||||
return block;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue