Skip to content

Commit 7c4459b

Browse files
authored
Merge pull request #2398 from nervosnetwork/testnet
Deploy to mainnet
2 parents 06661c2 + b4b5e8c commit 7c4459b

File tree

12 files changed

+27
-13
lines changed

12 files changed

+27
-13
lines changed

app/controllers/api/v2/fiber/graph_nodes_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def index
77
@page_size = params.fetch(:page_size, FiberGraphNode.default_per_page)
88
@nodes =
99
if params[:q].present?
10-
FiberGraphNode.where("alias = :q or peer_id = :q or node_id = :q", q: params[:q]).page(@page).per(@page_size)
10+
FiberGraphNode.where("node_name = :q or peer_id = :q or node_id = :q", q: params[:q]).page(@page).per(@page_size)
1111
else
1212
FiberGraphNode.all.page(@page).per(@page_size)
1313
end

app/models/block.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,15 @@ def invalid!
285285
uncle_blocks.delete_all
286286
# delete_address_txs_cache
287287
ckb_transaction_ids = ckb_transactions.pluck(:id)
288+
tx_hashes = ckb_transactions.pluck(:tx_hash)
288289
CellOutput.where(ckb_transaction_id: ckb_transaction_ids).delete_all
289290
CellInput.where(ckb_transaction_id: ckb_transaction_ids).delete_all
290291
AccountBook.where(ckb_transaction_id: ckb_transaction_ids).delete_all
291292
CellDependency.where(ckb_transaction_id: ckb_transaction_ids).delete_all
293+
cell_deps = CellDepsOutPoint.where(tx_hash: tx_hashes).select(:tx_hash, :cell_index)
294+
cell_deps.each do |cell_dep|
295+
Rails.cache.delete(["cell_output", cell_dep.tx_hash, cell_dep.cell_index])
296+
end
292297
HeaderDependency.where(ckb_transaction_id: ckb_transaction_ids).delete_all
293298
TokenTransfer.where(transaction_id: ckb_transaction_ids).delete_all
294299
Witness.where(ckb_transaction_id: ckb_transaction_ids).delete_all

app/models/daily_statistic.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# TODO
2-
# remove dao_depositors_count daily_dao_withdraw nodes_distribution nodes_count average_block_time columns
2+
# remove daily_dao_withdraw nodes_distribution nodes_count average_block_time columns
33
class DailyStatistic < ApplicationRecord
44
include AttrLogics
55

@@ -216,6 +216,10 @@ def liquidity
216216
select(:address_id)).distinct.count(:address_id)
217217
end
218218

219+
define_logic :dao_depositors_count do
220+
DaoEvent.depositor.created_before(ended_at).distinct.count(:address_id)
221+
end
222+
219223
define_logic :circulation_ratio do
220224
total_dao_deposit.to_i / circulating_supply
221225
end
@@ -512,7 +516,7 @@ def yesterday_daily_statistic
512516
if to_be_counted_date.beginning_of_day.to_i == Time.at(GENESIS_TIMESTAMP / 1000).in_time_zone.beginning_of_day.to_i \
513517
|| aggron_first_day? \
514518
|| yesterday_statistic.blank?
515-
OpenStruct.new(addresses_count: 0, total_dao_deposit: 0,
519+
OpenStruct.new(addresses_count: 0, total_dao_deposit: 0, dao_depositors_count: 0,
516520
unclaimed_compensation: 0, claimed_compensation: 0,
517521
average_deposit_time: 0, mining_reward: 0, deposit_compensation: 0,
518522
treasury_amount: 0, total_depositors_count: 0,

app/models/fiber_graph_node.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def open_channels_count
3434
# Table name: fiber_graph_nodes
3535
#
3636
# id :bigint not null, primary key
37-
# alias :string
37+
# node_name :string
3838
# node_id :string
3939
# addresses :string default([]), is an Array
4040
# timestamp :bigint

app/models/suggest_query.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def find_fiber_graph_nodes
163163
else
164164
query_key
165165
end
166-
fiber_graph_nodes = FiberGraphNode.where("alias = :query_key or peer_id = :query_key or node_id = :query_key", query_key: normalized_key)
166+
fiber_graph_nodes = FiberGraphNode.where("node_name = :query_key or peer_id = :query_key or node_id = :query_key", query_key: normalized_key)
167167
FiberGraphNodeSerializer.new(fiber_graph_nodes) if fiber_graph_nodes.present?
168168
end
169169
end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class FiberGraphNodeSerializer
22
include FastJsonapi::ObjectSerializer
33

4-
attributes :id, :alias, :node_id, :peer_id, :addresses, :timestamp, :chain_hash,
4+
attributes :id, :node_name, :node_id, :peer_id, :addresses, :timestamp, :chain_hash,
55
:auto_accept_min_ckb_funding_amount
66
end

app/services/charts/daily_statistic_generator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def updated_attrs
3030
daily_dao_depositors_count total_depositors_count unclaimed_compensation claimed_compensation deposit_compensation daily_dao_deposit total_dao_deposit circulating_supply circulation_ratio
3131
}
3232
others = %i{
33-
block_timestamp transactions_count addresses_count
33+
dao_depositors_count block_timestamp transactions_count addresses_count
3434
average_deposit_time mining_reward knowledge_size
3535
treasury_amount estimated_apc live_cells_count dead_cells_count avg_hash_rate
3636
avg_difficulty uncle_rate address_balance_distribution

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
json.data do
22
json.fiber_graph_nodes @nodes do |node|
3-
json.(node, :alias, :node_id, :addresses, :peer_id, :timestamp, :chain_hash, :connected_node_ids, :open_channels_count)
3+
json.(node, :node_name, :node_id, :addresses, :peer_id, :timestamp, :chain_hash, :connected_node_ids, :open_channels_count)
44
json.timestamp node.timestamp.to_s
55
json.auto_accept_min_ckb_funding_amount node.auto_accept_min_ckb_funding_amount.to_s
66
json.total_capacity node.total_capacity.to_s

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
json.data do
2-
json.(@node, :alias, :node_id, :addresses, :peer_id, :timestamp, :chain_hash, :connected_node_ids)
2+
json.(@node, :node_name, :node_id, :addresses, :peer_id, :timestamp, :chain_hash, :connected_node_ids)
33
json.timestamp @node.timestamp.to_s
44
json.auto_accept_min_ckb_funding_amount @node.auto_accept_min_ckb_funding_amount.to_s
55
json.total_capacity @node.total_capacity.to_s

app/workers/fiber_graph_detect_worker.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ def perform
1414
FiberGraphNode.where.not(node_id: @graph_node_ids).destroy_all
1515
# purge outdated graph channels
1616
FiberGraphChannel.where.not(channel_outpoint: @graph_channel_outpoints).destroy_all
17-
1817
# check channel is closed
1918
FiberGraphChannel.open_channels.each do |channel|
2019
funding_cell = channel.funding_cell
@@ -62,7 +61,7 @@ def fetch_channels(last_cursor)
6261

6362
def upsert_node_with_cfg_info(node)
6463
node_attributes = {
65-
alias: node["alias"],
64+
node_name: node["node_name"],
6665
node_id: node["node_id"],
6766
addresses: node["addresses"],
6867
timestamp: node["timestamp"].to_i(16),

0 commit comments

Comments
 (0)