height (header version) specific output PMMR root rules (#3147)
* height (header version) specific output PMMR root rules * cleanup * cleanup based on PR feedback * address feedback
This commit is contained in:
@@ -47,7 +47,10 @@ pub struct TxHashSetHandler {
|
||||
impl TxHashSetHandler {
|
||||
// gets roots
|
||||
fn get_roots(&self) -> Result<TxHashSet, Error> {
|
||||
Ok(TxHashSet::from_head(w(&self.chain)?))
|
||||
let res = TxHashSet::from_head(w(&self.chain)?).context(ErrorKind::Internal(
|
||||
"failed to read roots from txhashset".to_owned(),
|
||||
))?;
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
// gets last n outputs inserted in to the tree
|
||||
|
||||
+10
-7
@@ -116,13 +116,16 @@ pub struct TxHashSet {
|
||||
}
|
||||
|
||||
impl TxHashSet {
|
||||
pub fn from_head(head: Arc<chain::Chain>) -> TxHashSet {
|
||||
let roots = head.get_txhashset_roots();
|
||||
TxHashSet {
|
||||
output_root_hash: roots.output_root().to_hex(),
|
||||
range_proof_root_hash: roots.rproof_root.to_hex(),
|
||||
kernel_root_hash: roots.kernel_root.to_hex(),
|
||||
}
|
||||
/// A TxHashSet in the context of the api is simply the collection of PMMR roots.
|
||||
/// We can obtain these in a lightweight way by reading them from the head of the chain.
|
||||
/// We will have validated the roots on this header against the roots of the txhashset.
|
||||
pub fn from_head(chain: Arc<chain::Chain>) -> Result<TxHashSet, chain::Error> {
|
||||
let header = chain.head_header()?;
|
||||
Ok(TxHashSet {
|
||||
output_root_hash: header.output_root.to_hex(),
|
||||
range_proof_root_hash: header.range_proof_root.to_hex(),
|
||||
kernel_root_hash: header.kernel_root.to_hex(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user