diff --git a/crates/chain/src/chain_oracle.rs b/crates/chain/src/chain_oracle.rs index 2515adf8e..e736be035 100644 --- a/crates/chain/src/chain_oracle.rs +++ b/crates/chain/src/chain_oracle.rs @@ -17,7 +17,7 @@ pub trait ChainOracle { fn is_block_in_chain( &self, block: BlockId, - chain_tip: Option<&BlockId>, + chain_tip: BlockId, ) -> Result, Self::Error>; /// Get the best chain's chain tip. diff --git a/crates/chain/src/local_chain.rs b/crates/chain/src/local_chain.rs index b3022d1cc..d6cb20aa2 100644 --- a/crates/chain/src/local_chain.rs +++ b/crates/chain/src/local_chain.rs @@ -174,13 +174,8 @@ impl ChainOracle for LocalChain { fn is_block_in_chain( &self, block: BlockId, - chain_tip: Option<&BlockId>, + chain_tip: BlockId, ) -> Result, Self::Error> { - let chain_tip = match chain_tip { - Some(x) => x, - None => return Ok(None), - }; - if block.height > chain_tip.height { return Ok(None); } diff --git a/crates/chain/src/tx_graph.rs b/crates/chain/src/tx_graph.rs index eb2114029..e03bc884d 100644 --- a/crates/chain/src/tx_graph.rs +++ b/crates/chain/src/tx_graph.rs @@ -665,13 +665,18 @@ impl TxGraph { chain_tip: Option, txid: Txid, ) -> Result>, C::Error> { + let chain_tip = match chain_tip { + Some(tip) => tip, + None => return Ok(None), + }; + let (tx_node, anchors, last_seen) = match self.txs.get(&txid) { Some(v) => v, None => return Ok(None), }; for anchor in anchors { - match chain.is_block_in_chain(anchor.anchor_block(), chain_tip.as_ref())? { + match chain.is_block_in_chain(anchor.anchor_block(), chain_tip)? { Some(true) => return Ok(Some(ChainPosition::Confirmed(anchor))), _ => continue, } @@ -691,7 +696,7 @@ impl TxGraph { // this tx cannot exist in the best chain for conflicting_tx in self.walk_conflicts(tx, |_, txid| self.get_tx_node(txid)) { for block in conflicting_tx.anchors.iter().map(A::anchor_block) { - if chain.is_block_in_chain(block, chain_tip.as_ref())? == Some(true) { + if chain.is_block_in_chain(block, chain_tip)? == Some(true) { // conflicting tx is in best chain, so the current tx cannot be in best chain! return Ok(None); }