Skip to content

Commit

Permalink
Destruct TransactionView to get witness_hash
Browse files Browse the repository at this point in the history
  • Loading branch information
eval-exec committed Oct 15, 2024
1 parent c6f3bf6 commit 0d38341
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tx-pool/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,6 @@ impl TxPoolService {
declared_cycles: Option<Cycle>,
command_rx: Option<&mut watch::Receiver<ChunkCommand>>,
) -> Option<(Result<Completed, Reject>, Arc<Snapshot>)> {
let wtx_hash = tx.witness_hash();
let instant = Instant::now();
let is_sync_process = command_rx.is_none();

Expand Down Expand Up @@ -752,6 +751,7 @@ impl TxPoolService {
if verify_cache.is_none() {
// update cache
let txs_verify_cache = Arc::clone(&self.txs_verify_cache);
let wtx_hash = tx.destruct_wtx_hash();
tokio::spawn(async move {
let mut guard = txs_verify_cache.write().await;
guard.put(wtx_hash, verified);
Expand Down
9 changes: 9 additions & 0 deletions util/types/src/core/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,15 @@ macro_rules! define_inner_getter {
}

impl TransactionView {
/// Destruct TransactionView to get wtx_hash
pub fn destruct_wtx_hash(self) -> packed::Byte32 {
let TransactionView {
witness_hash: wtx_hash,
..
} = self;
wtx_hash
}

define_data_getter!(Transaction);
define_cache_getter!(hash, Byte32);
define_cache_getter!(witness_hash, Byte32);
Expand Down

0 comments on commit 0d38341

Please sign in to comment.