Skip to content

Commit

Permalink
proposals get validators from MetaData
Browse files Browse the repository at this point in the history
  • Loading branch information
classicalliu committed Aug 16, 2018
1 parent d4b0f08 commit 339b821
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 1 addition & 4 deletions app/controllers/api/statistics_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ def index
# }
# ]
def proposals
blocks = Block.select("header->>'proposer' as proposer")
proposers = blocks.distinct("proposers").map(&:proposer)

result = proposers.map do |proposer|
result = MetaData.last&.validators&.map do |proposer|
count = Block.where("header->>'proposer' = ?", proposer).count
{
"validator": proposer,
Expand Down
2 changes: 2 additions & 0 deletions spec/controllers/api/statistics_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
10.times.each do |i|
create :block_one, header: block_one_header.merge(timestamp: block_zero_header[:timestamp] + (20 + i) * 1000), cita_hash: "0x#{SecureRandom.hex(32)}", block_number: (20 + i)
end

create :meta_data, validators: [block_zero_proposer, block_one_proposer], block: Block.last
end


Expand Down

0 comments on commit 339b821

Please sign in to comment.