Bitcoin Core 29.99.0
P2P Digital Currency
blockfilterindex.cpp
Go to the documentation of this file.
1// Copyright (c) 2018-2022 The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#include <map>
6
7#include <clientversion.h>
8#include <common/args.h>
9#include <dbwrapper.h>
10#include <hash.h>
12#include <logging.h>
13#include <node/blockstorage.h>
14#include <undo.h>
15#include <util/fs_helpers.h>
16#include <util/syserror.h>
17
18/* The index database stores three items for each block: the disk location of the encoded filter,
19 * its dSHA256 hash, and the header. Those belonging to blocks on the active chain are indexed by
20 * height, and those belonging to blocks that have been reorganized out of the active chain are
21 * indexed by block hash. This ensures that filter data for any block that becomes part of the
22 * active chain can always be retrieved, alleviating timing concerns.
23 *
24 * The filters themselves are stored in flat files and referenced by the LevelDB entries. This
25 * minimizes the amount of data written to LevelDB and keeps the database values constant size. The
26 * disk location of the next block filter to be written (represented as a FlatFilePos) is stored
27 * under the DB_FILTER_POS key.
28 *
29 * Keys for the height index have the type [DB_BLOCK_HEIGHT, uint32 (BE)]. The height is represented
30 * as big-endian so that sequential reads of filters by height are fast.
31 * Keys for the hash index have the type [DB_BLOCK_HASH, uint256].
32 */
33constexpr uint8_t DB_BLOCK_HASH{'s'};
34constexpr uint8_t DB_BLOCK_HEIGHT{'t'};
35constexpr uint8_t DB_FILTER_POS{'P'};
36
37constexpr unsigned int MAX_FLTR_FILE_SIZE = 0x1000000; // 16 MiB
39constexpr unsigned int FLTR_FILE_CHUNK_SIZE = 0x100000; // 1 MiB
45constexpr size_t CF_HEADERS_CACHE_MAX_SZ{2000};
46
47namespace {
48
49struct DBVal {
50 uint256 hash;
51 uint256 header;
52 FlatFilePos pos;
53
54 SERIALIZE_METHODS(DBVal, obj) { READWRITE(obj.hash, obj.header, obj.pos); }
55};
56
57struct DBHeightKey {
58 int height;
59
60 explicit DBHeightKey(int height_in) : height(height_in) {}
61
62 template<typename Stream>
63 void Serialize(Stream& s) const
64 {
66 ser_writedata32be(s, height);
67 }
68
69 template<typename Stream>
70 void Unserialize(Stream& s)
71 {
72 const uint8_t prefix{ser_readdata8(s)};
73 if (prefix != DB_BLOCK_HEIGHT) {
74 throw std::ios_base::failure("Invalid format for block filter index DB height key");
75 }
76 height = ser_readdata32be(s);
77 }
78};
79
80struct DBHashKey {
81 uint256 hash;
82
83 explicit DBHashKey(const uint256& hash_in) : hash(hash_in) {}
84
85 SERIALIZE_METHODS(DBHashKey, obj) {
86 uint8_t prefix{DB_BLOCK_HASH};
88 if (prefix != DB_BLOCK_HASH) {
89 throw std::ios_base::failure("Invalid format for block filter index DB hash key");
90 }
91
92 READWRITE(obj.hash);
93 }
94};
95
96}; // namespace
97
98static std::map<BlockFilterType, BlockFilterIndex> g_filter_indexes;
99
100BlockFilterIndex::BlockFilterIndex(std::unique_ptr<interfaces::Chain> chain, BlockFilterType filter_type,
101 size_t n_cache_size, bool f_memory, bool f_wipe)
102 : BaseIndex(std::move(chain), BlockFilterTypeName(filter_type) + " block filter index")
103 , m_filter_type(filter_type)
104{
105 const std::string& filter_name = BlockFilterTypeName(filter_type);
106 if (filter_name.empty()) throw std::invalid_argument("unknown filter_type");
107
108 fs::path path = gArgs.GetDataDirNet() / "indexes" / "blockfilter" / fs::u8path(filter_name);
110
111 m_db = std::make_unique<BaseIndex::DB>(path / "db", n_cache_size, f_memory, f_wipe);
112 m_filter_fileseq = std::make_unique<FlatFileSeq>(std::move(path), "fltr", FLTR_FILE_CHUNK_SIZE);
113}
114
116{
118 options.connect_undo_data = true;
119 return options;
120}
121
122bool BlockFilterIndex::CustomInit(const std::optional<interfaces::BlockRef>& block)
123{
124 if (!m_db->Read(DB_FILTER_POS, m_next_filter_pos)) {
125 // Check that the cause of the read failure is that the key does not exist. Any other errors
126 // indicate database corruption or a disk failure, and starting the index would cause
127 // further corruption.
128 if (m_db->Exists(DB_FILTER_POS)) {
129 LogError("Cannot read current %s state; index may be corrupted",
130 GetName());
131 return false;
132 }
133
134 // If the DB_FILTER_POS is not set, then initialize to the first location.
137 }
138
139 if (block) {
140 auto op_last_header = ReadFilterHeader(block->height, block->hash);
141 if (!op_last_header) {
142 LogError("Cannot read last block filter header; index may be corrupted");
143 return false;
144 }
145 m_last_header = *op_last_header;
146 }
147
148 return true;
149}
150
152{
153 const FlatFilePos& pos = m_next_filter_pos;
154
155 // Flush current filter file to disk.
156 AutoFile file{m_filter_fileseq->Open(pos)};
157 if (file.IsNull()) {
158 LogError("Failed to open filter file %d", pos.nFile);
159 return false;
160 }
161 if (!file.Commit()) {
162 LogError("Failed to commit filter file %d", pos.nFile);
163 (void)file.fclose();
164 return false;
165 }
166 if (file.fclose() != 0) {
167 LogError("Failed to close filter file %d after commit: %s", pos.nFile, SysErrorString(errno));
168 return false;
169 }
170
171 batch.Write(DB_FILTER_POS, pos);
172 return true;
173}
174
175bool BlockFilterIndex::ReadFilterFromDisk(const FlatFilePos& pos, const uint256& hash, BlockFilter& filter) const
176{
177 AutoFile filein{m_filter_fileseq->Open(pos, true)};
178 if (filein.IsNull()) {
179 return false;
180 }
181
182 // Check that the hash of the encoded_filter matches the one stored in the db.
183 uint256 block_hash;
184 std::vector<uint8_t> encoded_filter;
185 try {
186 filein >> block_hash >> encoded_filter;
187 if (Hash(encoded_filter) != hash) {
188 LogError("Checksum mismatch in filter decode.");
189 return false;
190 }
191 filter = BlockFilter(GetFilterType(), block_hash, std::move(encoded_filter), /*skip_decode_check=*/true);
192 }
193 catch (const std::exception& e) {
194 LogError("Failed to deserialize block filter from disk: %s", e.what());
195 return false;
196 }
197
198 return true;
199}
200
202{
203 assert(filter.GetFilterType() == GetFilterType());
204
205 size_t data_size =
208
209 // If writing the filter would overflow the file, flush and move to the next one.
210 if (pos.nPos + data_size > MAX_FLTR_FILE_SIZE) {
211 AutoFile last_file{m_filter_fileseq->Open(pos)};
212 if (last_file.IsNull()) {
213 LogError("Failed to open filter file %d", pos.nFile);
214 return 0;
215 }
216 if (!last_file.Truncate(pos.nPos)) {
217 LogError("Failed to truncate filter file %d", pos.nFile);
218 return 0;
219 }
220 if (!last_file.Commit()) {
221 LogError("Failed to commit filter file %d", pos.nFile);
222 (void)last_file.fclose();
223 return 0;
224 }
225 if (last_file.fclose() != 0) {
226 LogError("Failed to close filter file %d after commit: %s", pos.nFile, SysErrorString(errno));
227 return 0;
228 }
229
230 pos.nFile++;
231 pos.nPos = 0;
232 }
233
234 // Pre-allocate sufficient space for filter data.
235 bool out_of_space;
236 m_filter_fileseq->Allocate(pos, data_size, out_of_space);
237 if (out_of_space) {
238 LogError("out of disk space");
239 return 0;
240 }
241
242 AutoFile fileout{m_filter_fileseq->Open(pos)};
243 if (fileout.IsNull()) {
244 LogError("Failed to open filter file %d", pos.nFile);
245 return 0;
246 }
247
248 fileout << filter.GetBlockHash() << filter.GetEncodedFilter();
249
250 if (fileout.fclose() != 0) {
251 LogError("Failed to close filter file %d: %s", pos.nFile, SysErrorString(errno));
252 return 0;
253 }
254
255 return data_size;
256}
257
258std::optional<uint256> BlockFilterIndex::ReadFilterHeader(int height, const uint256& expected_block_hash)
259{
260 std::pair<uint256, DBVal> read_out;
261 if (!m_db->Read(DBHeightKey(height), read_out)) {
262 return std::nullopt;
263 }
264
265 if (read_out.first != expected_block_hash) {
266 LogError("previous block header belongs to unexpected block %s; expected %s",
267 read_out.first.ToString(), expected_block_hash.ToString());
268 return std::nullopt;
269 }
270
271 return read_out.second.header;
272}
273
275{
276 BlockFilter filter(m_filter_type, *Assert(block.data), *Assert(block.undo_data));
277 const uint256& header = filter.ComputeHeader(m_last_header);
278 bool res = Write(filter, block.height, header);
279 if (res) m_last_header = header; // update last header
280 return res;
281}
282
283bool BlockFilterIndex::Write(const BlockFilter& filter, uint32_t block_height, const uint256& filter_header)
284{
285 size_t bytes_written = WriteFilterToDisk(m_next_filter_pos, filter);
286 if (bytes_written == 0) return false;
287
288 std::pair<uint256, DBVal> value;
289 value.first = filter.GetBlockHash();
290 value.second.hash = filter.GetHash();
291 value.second.header = filter_header;
292 value.second.pos = m_next_filter_pos;
293
294 if (!m_db->Write(DBHeightKey(block_height), value)) {
295 return false;
296 }
297
298 m_next_filter_pos.nPos += bytes_written;
299 return true;
300}
301
302[[nodiscard]] static bool CopyHeightIndexToHashIndex(CDBIterator& db_it, CDBBatch& batch,
303 const std::string& index_name, int height)
304{
305 DBHeightKey key(height);
306 db_it.Seek(key);
307
308 if (!db_it.GetKey(key) || key.height != height) {
309 LogError("unexpected key in %s: expected (%c, %d)",
310 index_name, DB_BLOCK_HEIGHT, height);
311 return false;
312 }
313
314 std::pair<uint256, DBVal> value;
315 if (!db_it.GetValue(value)) {
316 LogError("unable to read value in %s at key (%c, %d)",
317 index_name, DB_BLOCK_HEIGHT, height);
318 return false;
319 }
320
321 batch.Write(DBHashKey(value.first), std::move(value.second));
322 return true;
323}
324
326{
327 CDBBatch batch(*m_db);
328 std::unique_ptr<CDBIterator> db_it(m_db->NewIterator());
329
330 // During a reorg, we need to copy block filter that is getting disconnected from the
331 // height index to the hash index so we can still find it when the height index entry
332 // is overwritten.
333 if (!CopyHeightIndexToHashIndex(*db_it, batch, m_name, block.height)) {
334 return false;
335 }
336
337 // The latest filter position gets written in Commit by the call to the BaseIndex::Rewind.
338 // But since this creates new references to the filter, the position should get updated here
339 // atomically as well in case Commit fails.
341 if (!m_db->WriteBatch(batch)) return false;
342
343 // Update cached header to the previous block hash
345 return true;
346}
347
348static bool LookupOne(const CDBWrapper& db, const CBlockIndex* block_index, DBVal& result)
349{
350 // First check if the result is stored under the height index and the value there matches the
351 // block hash. This should be the case if the block is on the active chain.
352 std::pair<uint256, DBVal> read_out;
353 if (!db.Read(DBHeightKey(block_index->nHeight), read_out)) {
354 return false;
355 }
356 if (read_out.first == block_index->GetBlockHash()) {
357 result = std::move(read_out.second);
358 return true;
359 }
360
361 // If value at the height index corresponds to an different block, the result will be stored in
362 // the hash index.
363 return db.Read(DBHashKey(block_index->GetBlockHash()), result);
364}
365
366static bool LookupRange(CDBWrapper& db, const std::string& index_name, int start_height,
367 const CBlockIndex* stop_index, std::vector<DBVal>& results)
368{
369 if (start_height < 0) {
370 LogError("start height (%d) is negative", start_height);
371 return false;
372 }
373 if (start_height > stop_index->nHeight) {
374 LogError("start height (%d) is greater than stop height (%d)",
375 start_height, stop_index->nHeight);
376 return false;
377 }
378
379 size_t results_size = static_cast<size_t>(stop_index->nHeight - start_height + 1);
380 std::vector<std::pair<uint256, DBVal>> values(results_size);
381
382 DBHeightKey key(start_height);
383 std::unique_ptr<CDBIterator> db_it(db.NewIterator());
384 db_it->Seek(DBHeightKey(start_height));
385 for (int height = start_height; height <= stop_index->nHeight; ++height) {
386 if (!db_it->Valid() || !db_it->GetKey(key) || key.height != height) {
387 return false;
388 }
389
390 size_t i = static_cast<size_t>(height - start_height);
391 if (!db_it->GetValue(values[i])) {
392 LogError("unable to read value in %s at key (%c, %d)",
393 index_name, DB_BLOCK_HEIGHT, height);
394 return false;
395 }
396
397 db_it->Next();
398 }
399
400 results.resize(results_size);
401
402 // Iterate backwards through block indexes collecting results in order to access the block hash
403 // of each entry in case we need to look it up in the hash index.
404 for (const CBlockIndex* block_index = stop_index;
405 block_index && block_index->nHeight >= start_height;
406 block_index = block_index->pprev) {
407 uint256 block_hash = block_index->GetBlockHash();
408
409 size_t i = static_cast<size_t>(block_index->nHeight - start_height);
410 if (block_hash == values[i].first) {
411 results[i] = std::move(values[i].second);
412 continue;
413 }
414
415 if (!db.Read(DBHashKey(block_hash), results[i])) {
416 LogError("unable to read value in %s at key (%c, %s)",
417 index_name, DB_BLOCK_HASH, block_hash.ToString());
418 return false;
419 }
420 }
421
422 return true;
423}
424
425bool BlockFilterIndex::LookupFilter(const CBlockIndex* block_index, BlockFilter& filter_out) const
426{
427 DBVal entry;
428 if (!LookupOne(*m_db, block_index, entry)) {
429 return false;
430 }
431
432 return ReadFilterFromDisk(entry.pos, entry.hash, filter_out);
433}
434
435bool BlockFilterIndex::LookupFilterHeader(const CBlockIndex* block_index, uint256& header_out)
436{
438
439 bool is_checkpoint{block_index->nHeight % CFCHECKPT_INTERVAL == 0};
440
441 if (is_checkpoint) {
442 // Try to find the block in the headers cache if this is a checkpoint height.
443 auto header = m_headers_cache.find(block_index->GetBlockHash());
444 if (header != m_headers_cache.end()) {
445 header_out = header->second;
446 return true;
447 }
448 }
449
450 DBVal entry;
451 if (!LookupOne(*m_db, block_index, entry)) {
452 return false;
453 }
454
455 if (is_checkpoint &&
456 m_headers_cache.size() < CF_HEADERS_CACHE_MAX_SZ) {
457 // Add to the headers cache if this is a checkpoint height.
458 m_headers_cache.emplace(block_index->GetBlockHash(), entry.header);
459 }
460
461 header_out = entry.header;
462 return true;
463}
464
465bool BlockFilterIndex::LookupFilterRange(int start_height, const CBlockIndex* stop_index,
466 std::vector<BlockFilter>& filters_out) const
467{
468 std::vector<DBVal> entries;
469 if (!LookupRange(*m_db, m_name, start_height, stop_index, entries)) {
470 return false;
471 }
472
473 filters_out.resize(entries.size());
474 auto filter_pos_it = filters_out.begin();
475 for (const auto& entry : entries) {
476 if (!ReadFilterFromDisk(entry.pos, entry.hash, *filter_pos_it)) {
477 return false;
478 }
479 ++filter_pos_it;
480 }
481
482 return true;
483}
484
485bool BlockFilterIndex::LookupFilterHashRange(int start_height, const CBlockIndex* stop_index,
486 std::vector<uint256>& hashes_out) const
487
488{
489 std::vector<DBVal> entries;
490 if (!LookupRange(*m_db, m_name, start_height, stop_index, entries)) {
491 return false;
492 }
493
494 hashes_out.clear();
495 hashes_out.reserve(entries.size());
496 for (const auto& entry : entries) {
497 hashes_out.push_back(entry.hash);
498 }
499 return true;
500}
501
503{
504 auto it = g_filter_indexes.find(filter_type);
505 return it != g_filter_indexes.end() ? &it->second : nullptr;
506}
507
508void ForEachBlockFilterIndex(std::function<void (BlockFilterIndex&)> fn)
509{
510 for (auto& entry : g_filter_indexes) fn(entry.second);
511}
512
513bool InitBlockFilterIndex(std::function<std::unique_ptr<interfaces::Chain>()> make_chain, BlockFilterType filter_type,
514 size_t n_cache_size, bool f_memory, bool f_wipe)
515{
516 auto result = g_filter_indexes.emplace(std::piecewise_construct,
517 std::forward_as_tuple(filter_type),
518 std::forward_as_tuple(make_chain(), filter_type,
519 n_cache_size, f_memory, f_wipe));
520 return result.second;
521}
522
524{
525 return g_filter_indexes.erase(filter_type);
526}
527
529{
530 g_filter_indexes.clear();
531}
ArgsManager gArgs
Definition: args.cpp:42
const std::string & BlockFilterTypeName(BlockFilterType filter_type)
Get the human-readable name for a filter type.
BlockFilterType
Definition: blockfilter.h:93
constexpr unsigned int FLTR_FILE_CHUNK_SIZE
The pre-allocation chunk size for fltr?????.dat files.
bool DestroyBlockFilterIndex(BlockFilterType filter_type)
Destroy the block filter index with the given type.
void DestroyAllBlockFilterIndexes()
Destroy all open block filter indexes.
BlockFilterIndex * GetBlockFilterIndex(BlockFilterType filter_type)
Get a block filter index by type.
constexpr uint8_t DB_FILTER_POS
static bool LookupOne(const CDBWrapper &db, const CBlockIndex *block_index, DBVal &result)
constexpr unsigned int MAX_FLTR_FILE_SIZE
constexpr uint8_t DB_BLOCK_HASH
void ForEachBlockFilterIndex(std::function< void(BlockFilterIndex &)> fn)
Iterate over all running block filter indexes, invoking fn on each.
static bool CopyHeightIndexToHashIndex(CDBIterator &db_it, CDBBatch &batch, const std::string &index_name, int height)
constexpr size_t CF_HEADERS_CACHE_MAX_SZ
Maximum size of the cfheaders cache We have a limit to prevent a bug in filling this cache potentiall...
bool InitBlockFilterIndex(std::function< std::unique_ptr< interfaces::Chain >()> make_chain, BlockFilterType filter_type, size_t n_cache_size, bool f_memory, bool f_wipe)
Initialize a block filter index for the given type if one does not already exist.
static bool LookupRange(CDBWrapper &db, const std::string &index_name, int start_height, const CBlockIndex *stop_index, std::vector< DBVal > &results)
constexpr uint8_t DB_BLOCK_HEIGHT
static std::map< BlockFilterType, BlockFilterIndex > g_filter_indexes
static constexpr int CFCHECKPT_INTERVAL
Interval between compact filter checkpoints.
#define Assert(val)
Identity function.
Definition: check.h:106
fs::path GetDataDirNet() const
Get data directory path with appended network identifier.
Definition: args.h:234
Non-refcounted RAII wrapper for FILE*.
Definition: streams.h:371
Base class for indices of blockchain data.
Definition: base.h:43
const std::string & GetName() const LIFETIMEBOUND
Get the name of the index for display in logs.
Definition: base.h:139
const std::string m_name
Definition: base.h:106
Complete block filter struct as defined in BIP 157.
Definition: blockfilter.h:115
const uint256 & GetBlockHash() const LIFETIMEBOUND
Definition: blockfilter.h:135
const std::vector< unsigned char > & GetEncodedFilter() const LIFETIMEBOUND
Definition: blockfilter.h:138
uint256 ComputeHeader(const uint256 &prev_header) const
Compute the filter header given the previous one.
BlockFilterType GetFilterType() const
Definition: blockfilter.h:134
uint256 GetHash() const
Compute the filter hash.
BlockFilterIndex is used to store and retrieve block filters, hashes, and headers for a range of bloc...
std::unique_ptr< BaseIndex::DB > m_db
bool CustomInit(const std::optional< interfaces::BlockRef > &block) override
Initialize internal state from the database and block index.
bool LookupFilterRange(int start_height, const CBlockIndex *stop_index, std::vector< BlockFilter > &filters_out) const
Get a range of filters between two heights on a chain.
BlockFilterType GetFilterType() const
bool CustomRemove(const interfaces::BlockInfo &block) override
Rewind index by one block during a chain reorg.
bool CustomCommit(CDBBatch &batch) override
Virtual method called internally by Commit that can be overridden to atomically commit more index sta...
BlockFilterType m_filter_type
BlockFilterIndex(std::unique_ptr< interfaces::Chain > chain, BlockFilterType filter_type, size_t n_cache_size, bool f_memory=false, bool f_wipe=false)
Constructs the index, which becomes available to be queried.
interfaces::Chain::NotifyOptions CustomOptions() override
Return custom notification options for index.
std::unique_ptr< FlatFileSeq > m_filter_fileseq
bool LookupFilter(const CBlockIndex *block_index, BlockFilter &filter_out) const
Get a single filter by block.
bool ReadFilterFromDisk(const FlatFilePos &pos, const uint256 &hash, BlockFilter &filter) const
bool LookupFilterHashRange(int start_height, const CBlockIndex *stop_index, std::vector< uint256 > &hashes_out) const
Get a range of filter hashes between two heights on a chain.
bool CustomAppend(const interfaces::BlockInfo &block) override
Write update index entries for a newly connected block.
size_t WriteFilterToDisk(FlatFilePos &pos, const BlockFilter &filter)
bool LookupFilterHeader(const CBlockIndex *block_index, uint256 &header_out) EXCLUSIVE_LOCKS_REQUIRED(!m_cs_headers_cache)
Get a single filter header by block.
std::optional< uint256 > ReadFilterHeader(int height, const uint256 &expected_block_hash)
bool Write(const BlockFilter &filter, uint32_t block_height, const uint256 &filter_header)
FlatFilePos m_next_filter_pos
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:141
uint256 GetBlockHash() const
Definition: chain.h:243
int nHeight
height of the entry in the chain. The genesis block has height 0
Definition: chain.h:153
Batch of changes queued to be written to a CDBWrapper.
Definition: dbwrapper.h:72
void Write(const K &key, const V &value)
Definition: dbwrapper.h:96
bool GetValue(V &value)
Definition: dbwrapper.h:164
bool GetKey(K &key)
Definition: dbwrapper.h:154
void Seek(const K &key)
Definition: dbwrapper.h:145
bool Read(const K &key, V &value) const
Definition: dbwrapper.h:213
CDBIterator * NewIterator()
Definition: dbwrapper.cpp:360
std::string ToString() const
Definition: uint256.cpp:21
256-bit opaque blob.
Definition: uint256.h:196
static path u8path(const std::string &utf8_str)
Definition: fs.h:75
static bool create_directories(const std::filesystem::path &p)
Create directory (and if necessary its parents), unless the leaf directory already exists or is a sym...
Definition: fs.h:190
uint256 Hash(const T &in1)
Compute the 256-bit hash of an object.
Definition: hash.h:75
#define LogError(...)
Definition: logging.h:358
const char * prefix
Definition: rest.cpp:1117
static const int64_t values[]
A selection of numbers that do not trigger int64_t overflow when added/subtracted.
size_t GetSerializeSize(const T &t)
Definition: serialize.h:1094
void Serialize(Stream &, V)=delete
uint8_t ser_readdata8(Stream &s)
Definition: serialize.h:78
void ser_writedata32be(Stream &s, uint32_t obj)
Definition: serialize.h:68
#define SERIALIZE_METHODS(cls, obj)
Implement the Serialize and Unserialize methods by delegating to a single templated static method tha...
Definition: serialize.h:229
void Unserialize(Stream &, V)=delete
void ser_writedata8(Stream &s, uint8_t obj)
Definition: serialize.h:54
uint32_t ser_readdata32be(Stream &s)
Definition: serialize.h:96
#define READWRITE(...)
Definition: serialize.h:145
int nFile
Definition: flatfile.h:16
unsigned int nPos
Definition: flatfile.h:17
Block data sent with blockConnected, blockDisconnected notifications.
Definition: chain.h:79
const uint256 * prev_hash
Definition: chain.h:81
const CBlock * data
Definition: chain.h:85
const CBlockUndo * undo_data
Definition: chain.h:86
Options specifying which chain notifications are required.
Definition: chain.h:325
bool connect_undo_data
Include undo data with block connected notifications.
Definition: chain.h:327
#define LOCK(cs)
Definition: sync.h:259
std::string SysErrorString(int err)
Return system error string from errno value.
Definition: syserror.cpp:19
assert(!tx.IsCoinBase())