#[repr(C)]struct Metadata {
magic: u32,
version: u32,
best_block: BlockHash,
depth: u32,
validation_index: BlockHash,
alternative_tips: [BlockHash; 64],
fork_count: u32,
headers_file_size: usize,
fork_file_size: usize,
block_index_occupancy: usize,
index_capacity: usize,
checksum: DbCheckSum,
}Expand description
Metadata about our chainstate and the blocks we have. We need this to keep track of the network state, our local validation state and accumulator state
Fields§
§magic: u32A magic number to make sure we’re reading the right file and it was initialized correctly
version: u32The version of our flat chain store
best_block: BlockHashHash of the last block in the chain we believe has more work on
depth: u32How many blocks are pilled on this chain
validation_index: BlockHashWe actually validated blocks up to this point
alternative_tips: [BlockHash; 64]Blockchains are not fast-forward only, they might have “forks”, sometimes it’s useful to keep track of them, in case they become the best one. This keeps track of some tips we know about, but are not the best one. We don’t keep tips that are too deep or has too little work if compared to our best one
fork_count: u32How many blocks we have that are not in our main chain
headers_file_size: usizeThe size of the headers file map, in headers
fork_file_size: usizeThe size of the fork headers file map, in headers
block_index_occupancy: usizeThis holds how much of the index is occupied
index_capacity: usizeThe capacity of the index, in buckets
checksum: DbCheckSumThe checksum of our database, as it was in the last time we’ve flushed our data We can use this to check if our database is corrupted