[chain_redesign] Rename LocalChain::inner() to blocks()

Also, we can get rid of `LocalChain::get_blockhash`, since we can
already expose the internal map.

Additionally, tests and docs are improved.
This commit is contained in:
志宇
2023-05-05 19:49:30 +08:00
parent a56d289eef
commit 065c64a675
4 changed files with 19 additions and 35 deletions

View File

@@ -64,8 +64,8 @@ impl LocalChain {
}
}
/// Get a reference to the inner map of block height to hash.
pub fn inner(&self) -> &BTreeMap<u32, BlockHash> {
/// Get a reference to a map of block height to hash.
pub fn blocks(&self) -> &BTreeMap<u32, BlockHash> {
&self.blocks
}
@@ -76,11 +76,6 @@ impl LocalChain {
.map(|(&height, &hash)| BlockId { height, hash })
}
/// Get a [`BlockHash`] at the given height.
pub fn get_blockhash(&self, height: u32) -> Option<BlockHash> {
self.blocks.get(&height).cloned()
}
/// This is like the sparsechain's logic, expect we must guarantee that all invalidated heights
/// are to be re-filled.
pub fn determine_changeset(&self, update: &Self) -> Result<ChangeSet, UpdateNotConnectedError> {