Skip to content
This repository has been archived by the owner on Nov 5, 2023. It is now read-only.

Commit

Permalink
Add total transaction count to stats_inventory
Browse files Browse the repository at this point in the history
  • Loading branch information
madninja committed Jul 13, 2020
1 parent 060f908 commit c014701
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions migrations/1594674327-stats_inventory_txns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- migrations/1594674327-stats_inventory_txns.sql
-- :up

insert into stats_inventory (name, value) values
('transactions', (select COALESCE(count(*), 0) from transactions));


-- :down

delete from stats_inventory where name = 'transactions';
3 changes: 3 additions & 0 deletions src/be_db_stats.erl
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ load_block(Conn, _Hash, Block, _Sync, _Ledger, State=#state{}) ->
end, {State#state.stats, []},
[
<<"blocks">>,
<<"transactions">>,
<<"hotspots">>,
<<"consensus_groups">>,
<<"challenges">>
Expand All @@ -79,6 +80,8 @@ load_block(Conn, _Hash, Block, _Sync, _Ledger, State=#state{}) ->
-spec update(Name::binary(), Current::integer(), Block::blockchain_block:block()) -> New::integer().
update(<<"blocks">>, _Current, Block) ->
blockchain_block:height(Block);
update(<<"transactions">>, Current, Block) ->
Current + length(blockchain_block:transactions(Block));
update(<<"hotspots">>, Current, Block) ->
case lists:any(fun(Txn) ->
blockchain_txn:type(Txn) == blockchain_txn_add_gateway_v1
Expand Down

0 comments on commit c014701

Please sign in to comment.