Skip to content

Commit

Permalink
fix: set AutoSealConsensus best_block correctly (paradigmxyz#6612)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rjected authored Feb 14, 2024
1 parent 4c40f31 commit 7ef570f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions crates/consensus/auto-seal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,17 @@ pub(crate) struct Storage {
// == impl Storage ===

impl Storage {
fn new(header: SealedHeader) -> Self {
let (header, best_hash) = header.split();
/// Initializes the [Storage] with the given best block. This should be initialized with the
/// highest block in the chain, if there is a chain already stored on-disk.
fn new(best_block: SealedHeader) -> Self {
let (header, best_hash) = best_block.split();
let mut storage = StorageInner {
best_hash,
total_difficulty: header.difficulty,
best_block: header.number,
..Default::default()
};
storage.headers.insert(0, header);
storage.headers.insert(header.number, header);
storage.bodies.insert(best_hash, BlockBody::default());
Self { inner: Arc::new(RwLock::new(storage)) }
}
Expand Down

0 comments on commit 7ef570f

Please sign in to comment.