Handle adding new Tributaries

Removes last_block as an argument from Tendermint. It now loads from the DB as
needed. While slightly less performant, it's easiest and should be fine.
This commit is contained in:
Luke Parker
2023-04-23 03:48:50 -04:00
parent bf9ec410db
commit 2b09309adc
8 changed files with 149 additions and 80 deletions

View File

@@ -24,7 +24,7 @@ impl<D: Db> TributaryDb<D> {
txn.commit();
}
pub fn last_block(&self, genesis: [u8; 32]) -> [u8; 32] {
self.0.get(Self::block_key(genesis)).unwrap_or(genesis.to_vec()).try_into().unwrap()
self.0.get(Self::block_key(genesis)).map(|last| last.try_into().unwrap()).unwrap_or(genesis)
}
// This shouldn't need genesis? Yet it's saner to have then quibble about.