def results(address): colorvote = Colorvote(config) results = colorvote.db.get_results(address) return jsonify([{ 'address': r['address'], 'votes': r['votes'], } for r in results])
def info(): colorvote = Colorvote(config) info = colorvote.rpc.execute('getinfo') height = colorvote.db.get_setting('height') return jsonify( { 'connections': info['connections'], 'version': info['version'], 'height': height } )
def election(address): colorvote = Colorvote(config) election = colorvote.db.get_election(address) return jsonify({ 'time': election.time, 'block': election.block, 'txid': election.txid, 'address': election.address, 'unit': election.unit, 'metadata': election.metadata, })
def unspent(address): colorvote = Colorvote(config) transactions = colorvote.db.get_unspent(address) return jsonify([{ 'time': t['time'], 'block': t['block'], 'election': t['election'], 'amount': t['amount'], 'txid': t['txid'], 'n': t['n'] } for t in transactions])
def elections(): colorvote = Colorvote(config) elections = colorvote.db.get_elections() return jsonify([ { 'time': e.time, 'block': e.block, 'txid': e.txid, 'address': e.address, 'unit': e.unit, 'metadata': e.metadata, } for e in elections ])
def scan_blockchain(): colorvote = Colorvote(config) colorvote.scan()