Esempio n. 1
0
def results(address):
  colorvote = Colorvote(config)

  results = colorvote.db.get_results(address)

  return jsonify([{
    'address': r['address'],
    'votes': r['votes'],
  } for r in results])
Esempio n. 2
0
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
    }
  )
Esempio n. 3
0
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,
  })
Esempio n. 4
0
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])
Esempio n. 5
0
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
  ])
Esempio n. 6
0
def scan_blockchain():
  colorvote = Colorvote(config)

  colorvote.scan()