Skip to content

Commit 41f8817

Browse files
authored
feat: update fiber graph channels columns (#2386)
1 parent a3caf63 commit 41f8817

File tree

7 files changed

+51
-41
lines changed

7 files changed

+51
-41
lines changed

app/models/bitcoin_statistic.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ def self.refresh
3434
#
3535
# Indexes
3636
#
37-
# index_bitcoin_statistics_on_timestamp (timestamp) UNIQUE
37+
# index_bitcoin_statistics_on_timestamp (timestamp)
3838
#

app/models/fiber_graph_channel.rb

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,22 @@ def funding_cell
5151
#
5252
# Table name: fiber_graph_channels
5353
#
54-
# id :bigint not null, primary key
55-
# channel_outpoint :string
56-
# funding_tx_block_number :bigint
57-
# funding_tx_index :integer
58-
# node1 :string
59-
# node2 :string
60-
# last_updated_timestamp :bigint
61-
# created_timestamp :bigint
62-
# node1_to_node2_fee_rate :decimal(30, ) default(0)
63-
# node2_to_node1_fee_rate :decimal(30, ) default(0)
64-
# capacity :decimal(64, 2) default(0.0)
65-
# chain_hash :string
66-
# created_at :datetime not null
67-
# updated_at :datetime not null
68-
# udt_id :bigint
69-
# open_transaction_id :bigint
70-
# closed_transaction_id :bigint
54+
# id :bigint not null, primary key
55+
# channel_outpoint :string
56+
# node1 :string
57+
# node2 :string
58+
# created_timestamp :bigint
59+
# capacity :decimal(64, 2) default(0.0)
60+
# chain_hash :string
61+
# created_at :datetime not null
62+
# updated_at :datetime not null
63+
# udt_id :bigint
64+
# open_transaction_id :bigint
65+
# closed_transaction_id :bigint
66+
# last_updated_timestamp_of_node1 :bigint
67+
# last_updated_timestamp_of_node2 :bigint
68+
# fee_rate_of_node1 :decimal(30, ) default(0)
69+
# fee_rate_of_node2 :decimal(30, ) default(0)
7170
#
7271
# Indexes
7372
#

app/views/api/v2/fiber/graph_channels/index.jbuilder

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
json.data do
22
json.fiber_graph_channels @channels do |channel|
33
json.(channel, :channel_outpoint, :node1, :node2, :chain_hash, :open_transaction_info, :closed_transaction_info)
4-
json.funding_tx_block_number channel.funding_tx_block_number.to_s
5-
json.funding_tx_index channel.funding_tx_index.to_s
6-
json.last_updated_timestamp channel.last_updated_timestamp.to_s
4+
json.last_updated_timestamp_of_node1 channel.last_updated_timestamp_of_node1.to_s
5+
json.last_updated_timestamp_of_node2 channel.last_updated_timestamp_of_node2.to_s
76
json.created_timestamp channel.created_timestamp.to_s
8-
json.node1_to_node2_fee_rate channel.node1_to_node2_fee_rate.to_s
9-
json.node2_to_node1_fee_rate channel.node2_to_node1_fee_rate.to_s
7+
json.fee_rate_of_node1 channel.fee_rate_of_node1.to_s
8+
json.fee_rate_of_node2 channel.fee_rate_of_node2.to_s
109
json.capacity channel.capacity.to_s
1110
json.udt_cfg_info channel.udt_info
1211
end

app/views/api/v2/fiber/graph_nodes/show.jbuilder

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ json.data do
77

88
json.fiber_graph_channels @graph_channels do |channel|
99
json.(channel, :channel_outpoint, :node1, :node2, :chain_hash, :open_transaction_info, :closed_transaction_info, :udt_info)
10-
json.funding_tx_block_number channel.funding_tx_block_number.to_s
11-
json.funding_tx_index channel.funding_tx_index.to_s
12-
json.last_updated_timestamp channel.last_updated_timestamp.to_s
10+
json.last_updated_timestamp_of_node1 channel.last_updated_timestamp_of_node1.to_s
11+
json.last_updated_timestamp_of_node2 channel.last_updated_timestamp_of_node2.to_s
12+
json.fee_rate_of_node1 channel.fee_rate_of_node1.to_s
13+
json.fee_rate_of_node2 channel.fee_rate_of_node2.to_s
1314
json.created_timestamp channel.created_timestamp.to_s
14-
json.node1_to_node2_fee_rate channel.node1_to_node2_fee_rate.to_s
15-
json.node2_to_node1_fee_rate channel.node2_to_node1_fee_rate.to_s
1615
json.capacity channel.capacity.to_s
1716
end
1817
end

app/workers/fiber_graph_detect_worker.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,13 @@ def build_channel_attributes(channel)
100100

101101
{
102102
channel_outpoint:,
103-
funding_tx_block_number: channel["funding_tx_block_number"].to_i(16),
104-
funding_tx_index: channel["funding_tx_index"].to_i(16),
105103
node1: channel["node1"],
106104
node2: channel["node2"],
107-
last_updated_timestamp: channel["last_updated_timestamp"].to_i(16),
108105
created_timestamp: channel["created_timestamp"],
109-
node1_to_node2_fee_rate: channel["node1_to_node2_fee_rate"].to_i(16),
110-
node2_to_node1_fee_rate: channel["node2_to_node1_fee_rate"].to_i(16),
106+
last_updated_timestamp_of_node1: channel["last_updated_timestamp_of_node1"].to_i(16),
107+
last_updated_timestamp_of_node2: channel["last_updated_timestamp_of_node2"].to_i(16),
108+
fee_rate_of_node1: channel["fee_rate_of_node1"].to_i(16),
109+
fee_rate_of_node2: channel["fee_rate_of_node2"].to_i(16),
111110
capacity: channel["capacity"].to_i(16),
112111
chain_hash: channel["chain_hash"],
113112
open_transaction_id: open_transaction&.id,
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class UpdateFiberGraphChannels < ActiveRecord::Migration[7.0]
2+
def change
3+
remove_column :fiber_graph_channels, :funding_tx_block_number, :bigint
4+
remove_column :fiber_graph_channels, :funding_tx_index, :integer
5+
remove_column :fiber_graph_channels, :last_updated_timestamp, :bigint
6+
remove_column :fiber_graph_channels, :node1_to_node2_fee_rate, :decimal, precision: 30, default: 0.0
7+
remove_column :fiber_graph_channels, :node2_to_node1_fee_rate, :decimal, precision: 30, default: 0.0
8+
9+
add_column :fiber_graph_channels, :last_updated_timestamp_of_node1, :bigint
10+
add_column :fiber_graph_channels, :last_updated_timestamp_of_node2, :bigint
11+
add_column :fiber_graph_channels, :fee_rate_of_node1, :decimal, precision: 30, default: 0.0
12+
add_column :fiber_graph_channels, :fee_rate_of_node2, :decimal, precision: 30, default: 0.0
13+
end
14+
end

db/structure.sql

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,21 +1755,20 @@ ALTER SEQUENCE public.fiber_channels_id_seq OWNED BY public.fiber_channels.id;
17551755
CREATE TABLE public.fiber_graph_channels (
17561756
id bigint NOT NULL,
17571757
channel_outpoint character varying,
1758-
funding_tx_block_number bigint,
1759-
funding_tx_index integer,
17601758
node1 character varying,
17611759
node2 character varying,
1762-
last_updated_timestamp bigint,
17631760
created_timestamp bigint,
1764-
node1_to_node2_fee_rate numeric(30,0) DEFAULT 0.0,
1765-
node2_to_node1_fee_rate numeric(30,0) DEFAULT 0.0,
17661761
capacity numeric(64,2) DEFAULT 0.0,
17671762
chain_hash character varying,
17681763
created_at timestamp(6) without time zone NOT NULL,
17691764
updated_at timestamp(6) without time zone NOT NULL,
17701765
udt_id bigint,
17711766
open_transaction_id bigint,
1772-
closed_transaction_id bigint
1767+
closed_transaction_id bigint,
1768+
last_updated_timestamp_of_node1 bigint,
1769+
last_updated_timestamp_of_node2 bigint,
1770+
fee_rate_of_node1 numeric(30,0) DEFAULT 0.0,
1771+
fee_rate_of_node2 numeric(30,0) DEFAULT 0.0
17731772
);
17741773

17751774

@@ -4747,7 +4746,7 @@ CREATE UNIQUE INDEX index_bitcoin_annotations_on_ckb_transaction_id ON public.bi
47474746
-- Name: index_bitcoin_statistics_on_timestamp; Type: INDEX; Schema: public; Owner: -
47484747
--
47494748

4750-
CREATE UNIQUE INDEX index_bitcoin_statistics_on_timestamp ON public.bitcoin_statistics USING btree ("timestamp");
4749+
CREATE INDEX index_bitcoin_statistics_on_timestamp ON public.bitcoin_statistics USING btree ("timestamp");
47514750

47524751

47534752
--
@@ -6317,6 +6316,7 @@ INSERT INTO "schema_migrations" (version) VALUES
63176316
('20241223023654'),
63186317
('20241223060331'),
63196318
('20241225045757'),
6320-
('20241231022644');
6319+
('20241231022644'),
6320+
('20250103072945');
63216321

63226322

0 commit comments

Comments
 (0)