mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
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:
parent
eae7182823
commit
52caaa6fc8
@ -100,7 +100,7 @@ class App(BaseApplication):
|
|||||||
|
|
||||||
block = Block(app_hash=app_hash, height=height, transactions=[])
|
block = Block(app_hash=app_hash, height=height, transactions=[])
|
||||||
self.bigchaindb.store_block(block._asdict())
|
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']
|
abci_chain_height = 0 if known_chain is None else known_chain['height']
|
||||||
self.bigchaindb.store_abci_chain(abci_chain_height,
|
self.bigchaindb.store_abci_chain(abci_chain_height,
|
||||||
genesis.chain_id, True)
|
genesis.chain_id, True)
|
||||||
|
|||||||
@ -435,14 +435,13 @@ class BigchainDB(object):
|
|||||||
def store_pre_commit_state(self, state):
|
def store_pre_commit_state(self, state):
|
||||||
return backend.query.store_pre_commit_state(self.connection, 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`.
|
"""Store validator set at a given `height`.
|
||||||
NOTE: If the validator set already exists at that `height` then an
|
NOTE: If the validator set already exists at that `height` then an
|
||||||
exception will be raised.
|
exception will be raised.
|
||||||
"""
|
"""
|
||||||
return backend.query.store_validator_set(self.connection, {'height': height,
|
return backend.query.store_validator_set(self.connection, {'height': height,
|
||||||
'validators': validators,
|
'validators': validators})
|
||||||
'election_id': election_id})
|
|
||||||
|
|
||||||
def store_abci_chain(self, height, chain_id, is_synced=True):
|
def store_abci_chain(self, height, chain_id, is_synced=True):
|
||||||
return backend.query.store_abci_chain(self.connection, height,
|
return backend.query.store_abci_chain(self.connection, height,
|
||||||
|
|||||||
@ -45,5 +45,5 @@ class ValidatorElection(Election):
|
|||||||
validator_updates)
|
validator_updates)
|
||||||
|
|
||||||
updated_validator_set = [v for v in updated_validator_set if v['voting_power'] > 0]
|
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'])
|
return encode_validator(election.asset['data'])
|
||||||
|
|||||||
@ -427,7 +427,7 @@ def test_new_validator_set(b):
|
|||||||
|
|
||||||
validators = [node1]
|
validators = [node1]
|
||||||
updates = [node1_new_power, node2]
|
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_validator_set = new_validator_set(b.get_validators(1), updates)
|
||||||
|
|
||||||
updated_validators = []
|
updated_validators = []
|
||||||
|
|||||||
@ -234,7 +234,7 @@ def test_upsert_validator(b, node_key, node_keys, ed25519_node_keys):
|
|||||||
|
|
||||||
latest_block = b.get_latest_block()
|
latest_block = b.get_latest_block()
|
||||||
# reset the validator set
|
# 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
|
power = 1
|
||||||
public_key = '9B3119650DF82B9A5D8A12E38953EA47475C09F0C48A4E6A0ECE182944B24403'
|
public_key = '9B3119650DF82B9A5D8A12E38953EA47475C09F0C48A4E6A0ECE182944B24403'
|
||||||
@ -372,4 +372,4 @@ def reset_validator_set(b, node_keys, height):
|
|||||||
validators.append({'public_key': {'type': 'ed25519-base64',
|
validators.append({'public_key': {'type': 'ed25519-base64',
|
||||||
'value': node_pub},
|
'value': node_pub},
|
||||||
'voting_power': 10})
|
'voting_power': 10})
|
||||||
b.store_validator_set(height, validators, 'election_id')
|
b.store_validator_set(height, validators)
|
||||||
|
|||||||
@ -14,7 +14,7 @@ def test_get_validators_endpoint(b, client):
|
|||||||
'pub_key': {'data': '4E2685D9016126864733225BE00F005515200727FBAB1312FC78C8B76831255A',
|
'pub_key': {'data': '4E2685D9016126864733225BE00F005515200727FBAB1312FC78C8B76831255A',
|
||||||
'type': 'ed25519'},
|
'type': 'ed25519'},
|
||||||
'voting_power': 10}]
|
'voting_power': 10}]
|
||||||
b.store_validator_set(23, validator_set, 'election_id')
|
b.store_validator_set(23, validator_set)
|
||||||
|
|
||||||
res = client.get(VALIDATORS_ENDPOINT)
|
res = client.get(VALIDATORS_ENDPOINT)
|
||||||
assert is_validator(res.json[0])
|
assert is_validator(res.json[0])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user