Move validatorList method to RewardableValidators
This commit is contained in:
parent
212d796412
commit
fa36918944
|
@ -5,5 +5,4 @@ interface IBridgeValidators {
|
|||
function isValidator(address _validator) public view returns(bool);
|
||||
function requiredSignatures() public view returns(uint256);
|
||||
function owner() public view returns(address);
|
||||
function validatorList() public view returns (address[]);
|
||||
}
|
||||
|
|
|
@ -85,24 +85,6 @@ contract BaseBridgeValidators is EternalStorage, Ownable {
|
|||
return addressStorage[keccak256(abi.encodePacked("validatorsList", _address))];
|
||||
}
|
||||
|
||||
function validatorList() public view returns (address[]) {
|
||||
address [] memory list = new address[](validatorCount());
|
||||
uint256 counter = 0;
|
||||
address nextValidator = getNextValidator(F_ADDR);
|
||||
|
||||
while (nextValidator != F_ADDR) {
|
||||
list[counter] = nextValidator;
|
||||
nextValidator = getNextValidator(nextValidator);
|
||||
counter++;
|
||||
|
||||
if (nextValidator == address(0) ) {
|
||||
revert();
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
function deleteItemFromAddressStorage(string _mapName, address _address) internal {
|
||||
delete addressStorage[keccak256(abi.encodePacked(_mapName, _address))];
|
||||
}
|
||||
|
|
|
@ -67,6 +67,24 @@ contract RewardableValidators is BaseBridgeValidators {
|
|||
emit ValidatorRemoved(_validator);
|
||||
}
|
||||
|
||||
function validatorList() public view returns (address[]) {
|
||||
address [] memory list = new address[](validatorCount());
|
||||
uint256 counter = 0;
|
||||
address nextValidator = getNextValidator(F_ADDR);
|
||||
|
||||
while (nextValidator != F_ADDR) {
|
||||
list[counter] = nextValidator;
|
||||
nextValidator = getNextValidator(nextValidator);
|
||||
counter++;
|
||||
|
||||
if (nextValidator == address(0) ) {
|
||||
revert();
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
function getValidatorRewardAddress(address _validator) public view returns (address) {
|
||||
return addressStorage[keccak256(abi.encodePacked("validatorsRewards", _validator))];
|
||||
}
|
||||
|
|
|
@ -219,19 +219,4 @@ contract('BridgeValidators', async (accounts) => {
|
|||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('#Validators list', () => {
|
||||
it('should return validators list', async () => {
|
||||
// Given
|
||||
const validators = accounts.slice(0, 5)
|
||||
const { initialize, validatorList } = bridgeValidators
|
||||
await initialize(1, validators, owner, { from: owner }).should.be.fulfilled
|
||||
|
||||
// When
|
||||
const returnedList = await validatorList()
|
||||
|
||||
// Then
|
||||
returnedList.should.be.eql(validators)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue