Problem: Decided to no longer include the election_id when storing a validator_set

Solution: Removed the code to store the `election_id` and aligned the tests
This commit is contained in:
z-bowen 2018-09-07 15:29:26 +02:00
parent eae7182823
commit 52caaa6fc8
6 changed files with 8 additions and 9 deletions

View File

@ -100,7 +100,7 @@ class App(BaseApplication):
block = Block(app_hash=app_hash, height=height, transactions=[])
self.bigchaindb.store_block(block._asdict())
self.bigchaindb.store_validator_set(height + 1, validator_set, None)
self.bigchaindb.store_validator_set(height + 1, validator_set)
abci_chain_height = 0 if known_chain is None else known_chain['height']
self.bigchaindb.store_abci_chain(abci_chain_height,
genesis.chain_id, True)

View File

@ -435,14 +435,13 @@ class BigchainDB(object):
def store_pre_commit_state(self, state):
return backend.query.store_pre_commit_state(self.connection, state)
def store_validator_set(self, height, validators, election_id):
def store_validator_set(self, height, validators):
"""Store validator set at a given `height`.
NOTE: If the validator set already exists at that `height` then an
exception will be raised.
"""
return backend.query.store_validator_set(self.connection, {'height': height,
'validators': validators,
'election_id': election_id})
'validators': validators})
def store_abci_chain(self, height, chain_id, is_synced=True):
return backend.query.store_abci_chain(self.connection, height,

View File

@ -45,5 +45,5 @@ class ValidatorElection(Election):
validator_updates)
updated_validator_set = [v for v in updated_validator_set if v['voting_power'] > 0]
bigchain.store_validator_set(new_height+1, updated_validator_set, election.id)
bigchain.store_validator_set(new_height+1, updated_validator_set)
return encode_validator(election.asset['data'])

View File

@ -427,7 +427,7 @@ def test_new_validator_set(b):
validators = [node1]
updates = [node1_new_power, node2]
b.store_validator_set(1, validators, 'election_id')
b.store_validator_set(1, validators)
updated_validator_set = new_validator_set(b.get_validators(1), updates)
updated_validators = []

View File

@ -234,7 +234,7 @@ def test_upsert_validator(b, node_key, node_keys, ed25519_node_keys):
latest_block = b.get_latest_block()
# reset the validator set
b.store_validator_set(latest_block['height'], validators, 'previous_election_id')
b.store_validator_set(latest_block['height'], validators)
power = 1
public_key = '9B3119650DF82B9A5D8A12E38953EA47475C09F0C48A4E6A0ECE182944B24403'
@ -372,4 +372,4 @@ def reset_validator_set(b, node_keys, height):
validators.append({'public_key': {'type': 'ed25519-base64',
'value': node_pub},
'voting_power': 10})
b.store_validator_set(height, validators, 'election_id')
b.store_validator_set(height, validators)

View File

@ -14,7 +14,7 @@ def test_get_validators_endpoint(b, client):
'pub_key': {'data': '4E2685D9016126864733225BE00F005515200727FBAB1312FC78C8B76831255A',
'type': 'ed25519'},
'voting_power': 10}]
b.store_validator_set(23, validator_set, 'election_id')
b.store_validator_set(23, validator_set)
res = client.get(VALIDATORS_ENDPOINT)
assert is_validator(res.json[0])