mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Extend election show with migration data.
This commit is contained in:
parent
24ca0b32a9
commit
87eaf4da55
@ -118,7 +118,6 @@ def run_election_new(args, bigchain):
|
|||||||
|
|
||||||
|
|
||||||
def create_new_election(sk, bigchain, election_class, data):
|
def create_new_election(sk, bigchain, election_class, data):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
key = load_node_key(sk)
|
key = load_node_key(sk)
|
||||||
voters = election_class.recipients(bigchain)
|
voters = election_class.recipients(bigchain)
|
||||||
@ -362,6 +361,7 @@ def create_parser():
|
|||||||
help='The election_id of the election.')
|
help='The election_id of the election.')
|
||||||
approve_election_parser.add_argument('--private-key',
|
approve_election_parser.add_argument('--private-key',
|
||||||
dest='sk',
|
dest='sk',
|
||||||
|
required=True,
|
||||||
help='Path to the private key of the election initiator.')
|
help='Path to the private key of the election initiator.')
|
||||||
|
|
||||||
show_election_parser = election_subparser.add_parser('show',
|
show_election_parser = election_subparser.add_parser('show',
|
||||||
|
|||||||
@ -13,6 +13,7 @@ elections = {
|
|||||||
},
|
},
|
||||||
'--private-key': {
|
'--private-key': {
|
||||||
'dest': 'sk',
|
'dest': 'sk',
|
||||||
|
'required': True,
|
||||||
'help': 'Path to the private key of the election initiator.'
|
'help': 'Path to the private key of the election initiator.'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -22,6 +23,7 @@ elections = {
|
|||||||
'args': {
|
'args': {
|
||||||
'--private-key': {
|
'--private-key': {
|
||||||
'dest': 'sk',
|
'dest': 'sk',
|
||||||
|
'required': True,
|
||||||
'help': 'Path to the private key of the election initiator.'
|
'help': 'Path to the private key of the election initiator.'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
import json
|
||||||
|
|
||||||
from bigchaindb.common.schema import TX_SCHEMA_CHAIN_MIGRATION_ELECTION
|
from bigchaindb.common.schema import TX_SCHEMA_CHAIN_MIGRATION_ELECTION
|
||||||
from bigchaindb.elections.election import Election
|
from bigchaindb.elections.election import Election
|
||||||
|
|
||||||
@ -20,3 +22,24 @@ class ChainMigrationElection(Election):
|
|||||||
|
|
||||||
def on_approval(self, bigchain, *args, **kwargs):
|
def on_approval(self, bigchain, *args, **kwargs):
|
||||||
bigchain.migrate_abci_chain()
|
bigchain.migrate_abci_chain()
|
||||||
|
|
||||||
|
def show_election(self, bigchain):
|
||||||
|
output = super().show_election(bigchain)
|
||||||
|
chain = bigchain.get_latest_abci_chain()
|
||||||
|
if chain is None or chain['is_synced']:
|
||||||
|
return output
|
||||||
|
|
||||||
|
output += f'\nchain_id={chain["chain_id"]}'
|
||||||
|
block = bigchain.get_latest_block()
|
||||||
|
output += f'\napp_hash={block["app_hash"]}'
|
||||||
|
validators = [
|
||||||
|
{
|
||||||
|
'pub_key': {
|
||||||
|
'type': 'tendermint/PubKeyEd25519',
|
||||||
|
'value': k,
|
||||||
|
},
|
||||||
|
'power': v,
|
||||||
|
} for k, v in self.get_validators(bigchain).items()
|
||||||
|
]
|
||||||
|
output += f'\nvalidators={json.dumps(validators, indent=4)}'
|
||||||
|
return output
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user