@Dev Team
Is there any API to find which blocks an account has forged, and how many fees the account got?
Thanks.
You can walk block chain and compare the "generator" of the block against the account number.
Here's some ruby (extracted from my soon to be released ruby client library):
#!/usr/bin/env ruby
require "rubygems"
require 'json'
require 'httparty'
def get(server, cmd, args={})
a = args.map { |k,v| "#{k}=#{v}" }.join("&")
url = "http://#{server}:7874/nxt?requestType=#{cmd}&#{a}"
JSON.parse(HTTParty.get(URI::escape(url)).body)
end
def get_block(id)
get("localhost", "getBlock", {"block" => id})
end
account = ARGV[0]
last_block_id = get("localhost", "getState")["lastBlock"]
blocks = {}
fees = 0
while last_block_id
block = get_block(last_block_id)
if block["generator"] == account
fee = block["totalFee"]
puts "#{last_block_id} - #{fee}"
fees += fee
end
last_block_id = block["previousBlock"]
end
puts "#{account} earned #{fees} nxt."
Save this as "forged.rb" and "chmod +x".
./forged.rb ACCOUNT