Skip to content

Commit

Permalink
feat: update confirmation_time after tx committed
Browse files Browse the repository at this point in the history
Signed-off-by: Miles Zhang <[email protected]>
  • Loading branch information
zmcNotafraid committed Sep 5, 2024
1 parent 4181c20 commit a8450d1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/models/ckb_sync/new_node_data_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ def build_ckb_transactions!(node_block, local_block, inputs, outputs, outputs_da
# locate correct record according to tx_hash
binary_hashes = CkbUtils.hexes_to_bins_sql(hashes)
pending_txs = CkbTransaction.where("tx_hash IN (#{binary_hashes})").where(tx_status: :pending).pluck(
:tx_hash, :created_at
:tx_hash, :confirmation_time
)
CkbTransaction.where("tx_hash IN (#{binary_hashes})").update_all tx_status: "committed"

Expand All @@ -1283,7 +1283,7 @@ def build_ckb_transactions!(node_block, local_block, inputs, outputs, outputs_da
end.map do |tx|
{
id: tx["id"], tx_status: :committed,
confirmation_time: (tx["block_timestamp"].to_i / 1000) - hash_to_pool_times[tx["tx_hash"].tr("\\", "0")].to_i
confirmation_time: (tx["block_timestamp"].to_i - hash_to_pool_times[tx["tx_hash"].tr("\\", "0")].to_i) / 1000
}
end
CkbTransaction.upsert_all(confirmation_time_attrs, update_only: [:confirmation_time],
Expand Down

0 comments on commit a8450d1

Please sign in to comment.