Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy to testnet #2352

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/views/api/v2/fiber/graph_nodes/show.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ json.data do
json.udt_cfg_infos @node.udt_cfg_infos

json.fiber_graph_channels @graph_channels do |channel|
json.(channel, :channel_outpoint, :node1, :node2, :chain_hash, :open_transaction_info, :closed_transaction_info)
json.(channel, :channel_outpoint, :node1, :node2, :chain_hash, :open_transaction_info, :closed_transaction_info, :udt_info)
json.funding_tx_block_number channel.funding_tx_block_number.to_s
json.funding_tx_index channel.funding_tx_index.to_s
json.last_updated_timestamp channel.last_updated_timestamp.to_s
Expand Down
12 changes: 11 additions & 1 deletion app/workers/fiber_graph_detect_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@ class FiberGraphDetectWorker
include Sidekiq::Worker
sidekiq_options queue: "fiber"

attr_accessor :graph_node_ids, :graph_channel_outpoint

def perform
@graph_node_ids = []
@graph_channel_outpoints = []

# sync graph nodes and channels
["nodes", "channels"].each { fetch_graph_infos(_1) }
# purge outdated graph nodes
FiberGraphNode.where.not(node_id: @graph_node_ids).destroy_all
# purge outdated graph channels
FiberGraphChannel.where.not(channel_outpoint: @graph_channel_outpoints).destroy_all

# check channel is closed
FiberGraphChannel.open_channels.each do |channel|
Expand Down Expand Up @@ -61,7 +70,7 @@ def upsert_node_with_cfg_info(node)
peer_id: extract_peer_id(node["addresses"]),
auto_accept_min_ckb_funding_amount: node["auto_accept_min_ckb_funding_amount"],
}

@graph_node_ids << node_attributes[:node_id]
fiber_graph_node = FiberGraphNode.upsert(node_attributes, unique_by: %i[node_id], returning: %i[id])

return unless fiber_graph_node && node["udt_cfg_infos"].present?
Expand All @@ -87,6 +96,7 @@ def build_channel_attributes(channel)

channel_outpoint = channel["channel_outpoint"]
open_transaction = CkbTransaction.find_by(tx_hash: channel_outpoint[0..65])
@graph_channel_outpoints << channel_outpoint

{
channel_outpoint:,
Expand Down
Loading