Add basic getters to tributary

This commit is contained in:
Luke Parker
2023-04-15 00:41:48 -04:00
parent 124b994c23
commit f48022c6eb
2 changed files with 19 additions and 0 deletions

View File

@@ -126,6 +126,16 @@ impl<D: Db, T: Transaction, P: P2p> Tributary<D, T, P> {
Some(Self { network, synced_block, messages })
}
pub fn tip(&self) -> [u8; 32] {
self.network.blockchain.read().unwrap().tip()
}
pub fn block(&self, hash: &[u8; 32]) -> Option<Block<T>> {
self.network.blockchain.read().unwrap().block(hash)
}
pub fn commit(&self, hash: &[u8; 32]) -> Option<Vec<u8>> {
self.network.blockchain.read().unwrap().commit(hash)
}
pub fn provide_transaction(&self, tx: T) -> Result<(), ProvidedError> {
self.network.blockchain.write().unwrap().provide_transaction(tx)
}