mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Problem: MigrationElection needed to be added to the list of allowed operations
Solution: Added it
This commit is contained in:
parent
4493cad6d6
commit
3f81e7eeaa
@ -7,6 +7,7 @@ import logging
|
|||||||
|
|
||||||
from bigchaindb.log import DEFAULT_LOGGING_CONFIG as log_config
|
from bigchaindb.log import DEFAULT_LOGGING_CONFIG as log_config
|
||||||
from bigchaindb.lib import BigchainDB # noqa
|
from bigchaindb.lib import BigchainDB # noqa
|
||||||
|
from bigchaindb.migrations.migration_election import MigrationElection
|
||||||
from bigchaindb.version import __version__ # noqa
|
from bigchaindb.version import __version__ # noqa
|
||||||
from bigchaindb.core import App # noqa
|
from bigchaindb.core import App # noqa
|
||||||
|
|
||||||
@ -99,4 +100,5 @@ from bigchaindb.elections.vote import Vote # noqa
|
|||||||
Transaction.register_type(Transaction.CREATE, models.Transaction)
|
Transaction.register_type(Transaction.CREATE, models.Transaction)
|
||||||
Transaction.register_type(Transaction.TRANSFER, models.Transaction)
|
Transaction.register_type(Transaction.TRANSFER, models.Transaction)
|
||||||
Transaction.register_type(ValidatorElection.OPERATION, ValidatorElection)
|
Transaction.register_type(ValidatorElection.OPERATION, ValidatorElection)
|
||||||
|
Transaction.register_type(MigrationElection.OPERATION, MigrationElection)
|
||||||
Transaction.register_type(Vote.OPERATION, Vote)
|
Transaction.register_type(Vote.OPERATION, Vote)
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import copy
|
|||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from bigchaindb.migrations.migration_election import MigrationElection
|
||||||
from bigchaindb.utils import load_node_key
|
from bigchaindb.utils import load_node_key
|
||||||
from bigchaindb.common.exceptions import (DatabaseDoesNotExist,
|
from bigchaindb.common.exceptions import (DatabaseDoesNotExist,
|
||||||
ValidationError)
|
ValidationError)
|
||||||
@ -159,6 +160,40 @@ def run_election_new_upsert_validator(args, bigchain):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def run_election_new_migration(args, bigchain):
|
||||||
|
"""Initiates an election to halt block production
|
||||||
|
|
||||||
|
:param args: dict
|
||||||
|
args = {
|
||||||
|
'sk': the path to the private key of the node calling the election (str)
|
||||||
|
}
|
||||||
|
:param bigchain: an instance of BigchainDB
|
||||||
|
:return: election_id or `False` in case of failure
|
||||||
|
"""
|
||||||
|
|
||||||
|
try:
|
||||||
|
key = load_node_key(args.sk)
|
||||||
|
voters = MigrationElection.recipients(bigchain)
|
||||||
|
election = MigrationElection.generate([key.public_key],
|
||||||
|
voters,
|
||||||
|
{}, None).sign([key.private_key])
|
||||||
|
election.validate(bigchain)
|
||||||
|
except ValidationError as e:
|
||||||
|
logger.error(e)
|
||||||
|
return False
|
||||||
|
except FileNotFoundError as fd_404:
|
||||||
|
logger.error(fd_404)
|
||||||
|
return False
|
||||||
|
|
||||||
|
resp = bigchain.write_transaction(election, 'broadcast_tx_commit')
|
||||||
|
if resp == (202, ''):
|
||||||
|
logger.info('[SUCCESS] Submitted proposal with id: {}'.format(election.id))
|
||||||
|
return election.id
|
||||||
|
else:
|
||||||
|
logger.error('Failed to commit election proposal')
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def run_election_approve(args, bigchain):
|
def run_election_approve(args, bigchain):
|
||||||
"""Approve an election
|
"""Approve an election
|
||||||
|
|
||||||
|
|||||||
@ -63,6 +63,7 @@ definitions:
|
|||||||
- CREATE
|
- CREATE
|
||||||
- TRANSFER
|
- TRANSFER
|
||||||
- VALIDATOR_ELECTION
|
- VALIDATOR_ELECTION
|
||||||
|
- MIGRATION_ELECTION
|
||||||
- VOTE
|
- VOTE
|
||||||
asset:
|
asset:
|
||||||
type: object
|
type: object
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user