Skip to content

Commit

Permalink
some more get_transaction refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
blckngm committed May 25, 2022
1 parent a96a858 commit 08f50a4
Showing 1 changed file with 9 additions and 28 deletions.
37 changes: 9 additions & 28 deletions crates/block-producer/src/poller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ use gw_chain::chain::{
Chain, ChallengeCell, L1Action, L1ActionContext, RevertL1ActionContext, RevertedL1Action,
SyncParam,
};
use gw_jsonrpc_types::{
blockchain::TransactionWithStatus,
ckb_jsonrpc_types::{BlockNumber, HeaderView, Uint32},
};
use gw_jsonrpc_types::ckb_jsonrpc_types::{BlockNumber, HeaderView, Uint32};
use gw_rpc_client::{
indexer_types::{Order, Pagination, ScriptType, SearchKey, SearchKeyFilter, Tx},
rpc_client::RPCClient,
Expand Down Expand Up @@ -236,16 +233,12 @@ impl ChainUpdater {
}
}

let tx: Option<TransactionWithStatus> = self
let tx_with_status = self
.rpc_client
.ckb
.request(
"get_transaction",
Some(ClientParams::Array(vec![json!(tx_hash)])),
)
.await?;
let tx_with_status =
tx.ok_or_else(|| QueryL1TxError::new(tx_hash, anyhow!("cannot locate tx")))?;
.get_transaction_with_status(tx_hash.0.into())
.await?
.ok_or_else(|| QueryL1TxError::new(tx_hash, anyhow!("cannot locate tx")))?;
let tx = {
let tx: ckb_types::packed::Transaction = tx_with_status
.transaction
Expand Down Expand Up @@ -531,24 +524,12 @@ impl ChainUpdater {
// Load cell denoted by the transaction input
let tx_hash: H256 = input.previous_output().tx_hash().unpack();
let index = input.previous_output().index().unpack();
let tx: Option<TransactionWithStatus> = self
let tx = self
.rpc_client
.ckb
.request(
"get_transaction",
Some(ClientParams::Array(vec![json!(tx_hash)])),
)
.await?;
let tx_with_status =
tx.ok_or_else(|| QueryL1TxError::new(&tx_hash, anyhow!("cannot locate tx")))?;
let tx = {
let tx: ckb_types::packed::Transaction = tx_with_status
.transaction
.ok_or_else(|| QueryL1TxError::new(&tx_hash, anyhow!("cannot locate tx")))?
.inner
.into();
Transaction::new_unchecked(tx.as_bytes())
};
.get_transaction(tx_hash.0.into())
.await?
.ok_or_else(|| QueryL1TxError::new(&tx_hash, anyhow!("cannot locate tx")))?;
let cell_output = tx
.raw()
.outputs()
Expand Down

0 comments on commit 08f50a4

Please sign in to comment.