mirror of
https://github.com/mimblewimble/grin.git
synced 2025-05-01 06:41:15 +03:00
Fix issue where we have no metadata for a block (#938)
when restarting node before initial sync completed
This commit is contained in:
parent
b9de134209
commit
bc6342ea65
3 changed files with 21 additions and 6 deletions
|
@ -160,15 +160,20 @@ impl Chain {
|
|||
|
||||
// check if we have a head in store, otherwise the genesis block is it
|
||||
let head = store.head();
|
||||
|
||||
let txhashset_md = match head {
|
||||
Ok(h) => {
|
||||
// Add the height to the metadata for the use of the rewind log, as this isn't
|
||||
// stored
|
||||
let mut ts = store.get_block_pmmr_file_metadata(&h.last_block_h)?;
|
||||
ts.output_file_md.block_height = h.height;
|
||||
ts.rproof_file_md.block_height = h.height;
|
||||
ts.kernel_file_md.block_height = h.height;
|
||||
Some(ts)
|
||||
if let Ok(mut ts) = store.get_block_pmmr_file_metadata(&h.last_block_h) {
|
||||
ts.output_file_md.block_height = h.height;
|
||||
ts.rproof_file_md.block_height = h.height;
|
||||
ts.kernel_file_md.block_height = h.height;
|
||||
Some(ts)
|
||||
} else {
|
||||
debug!(LOGGER, "metadata not found for {} @ {}", h.height, h.hash());
|
||||
None
|
||||
}
|
||||
}
|
||||
Err(NotFoundErr) => None,
|
||||
Err(e) => return Err(Error::StoreErr(e, "chain init load head".to_owned())),
|
||||
|
@ -178,6 +183,7 @@ impl Chain {
|
|||
txhashset::TxHashSet::open(db_root.clone(), store.clone(), txhashset_md)?;
|
||||
|
||||
let head = store.head();
|
||||
|
||||
let head = match head {
|
||||
Ok(h) => h,
|
||||
Err(NotFoundErr) => {
|
||||
|
|
|
@ -116,7 +116,8 @@ impl Server {
|
|||
global::ChainTypes::AutomatedTesting => genesis::genesis_dev(),
|
||||
_ => pow::mine_genesis_block(config.mining_config.clone())?,
|
||||
};
|
||||
info!(LOGGER, "Starting server, genesis block: {}", genesis.hash(),);
|
||||
|
||||
info!(LOGGER, "Starting server, genesis block: {}", genesis.hash());
|
||||
|
||||
let shared_chain = Arc::new(chain::Chain::init(
|
||||
config.db_root.clone(),
|
||||
|
|
|
@ -248,6 +248,14 @@ impl MessageHandler for Protocol {
|
|||
tmp_zip,
|
||||
self.addr,
|
||||
);
|
||||
|
||||
debug!(
|
||||
LOGGER,
|
||||
"handle_payload: txhashset archive for {} at {}, DONE",
|
||||
sm_arch.hash,
|
||||
sm_arch.height
|
||||
);
|
||||
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue