Skip to content

Commit

Permalink
fix for the last fix about burnt calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Germain committed Mar 14, 2024
1 parent b90263a commit de20368
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion huginn_callisto_network_agent.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)

Gem::Specification.new do |spec|
spec.name = "huginn_callisto_network_agent"
spec.version = '0.1.85'
spec.version = '0.1.86'
spec.authors = ["Nicolas Germain"]
spec.email = ["ngermain@hihouhou.com"]

Expand Down
16 changes: 9 additions & 7 deletions lib/huginn_callisto_network_agent/callisto_network_agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -455,30 +455,32 @@ def get_tx_stats()
internal = true
tx_list = []
burnt_clo = 0
burnt_type2 = 0
burnt_dead = 0
(interpolated['first_block']..interpolated['last_block']).each do |i|
transactions = get_data(i.to_i,internal)
burnt_per_block = 0
burnt_type2_per_block = 0
fees = 0
transactions['result']['transactions'].each do |tx|
gas_fee = transactions['result']['baseFeePerGas'].to_i(16)
if !tx.empty?
tx_list << tx
if tx['type'] == "0x2"
gas_fee = transactions['result']['baseFeePerGas'].to_i(16)
fees = ( transactions['result']['gasUsed'].to_i(16) * gas_fee.to_f ) / (10 ** 18)
else
fees = 0
tx_hash_info = get_tx_receipt(tx['hash'])
fees = ( tx_hash_info['result']['gasUsed'].to_i(16) * gas_fee.to_f ) / (10 ** 18)
end
if tx['to'] == dead_address
burnt = tx['value'].to_i(16).to_f / 10**18
else
burnt = 0
end
end
burnt_type2 += fees
burnt_type2_per_block += fees
burnt_dead += burnt
end
burnt_per_block += ( burnt_dead + burnt_type2_per_block )
burnt_clo += burnt_per_block
end
burnt_clo = ( burnt_type2 / tx_list.count ) + burnt_dead
top_tx = most_common_from(tx_list)
top_count = tx_list.count { |hash| hash['from'] == top_tx }
miners_count = tx_list.select { |hash| all_miners.include?(hash['from']) }
Expand Down

0 comments on commit de20368

Please sign in to comment.