IValidator

Git Source

This is the interface for the validator contract. You'll find all the events and external functions.

Functions

addValidators

Adds new validators. This function can only be called by the owner of validator contract. Note that this reverts if new validators to add are already validators.

function addValidators(address[] calldata validators) external;

Parameters

NameTypeDescription
validatorsaddress[]New validator addresses to add

removeValidators

Removes exist validators. This function can only be called by the owner of validator contract. Note that this reverts if validators to remove are not validators.

function removeValidators(address[] calldata validators) external;

Parameters

NameTypeDescription
validatorsaddress[]Validator addresses to remove

changeRequiredNumber

Change the required number of validators. Requirements::

  1. the caller is owner of validator contract.
  2. new required number > validators length.
  3. new required number is zero.
function changeRequiredNumber(uint256 newRequiredNumber) external;

Parameters

NameTypeDescription
newRequiredNumberuint256New required number to set.

isValidator

Returns whether an address is validator or not.

function isValidator(address addr) external view returns (bool);

Parameters

NameTypeDescription
addraddressAddress to query.

getValidators

Returns all the validators.

function getValidators() external view returns (address[] memory validators);

getRequiredNumber

Returns current required number.

function getRequiredNumber() external view returns (uint256);

checkThreshold

Checks whether the voteCount passes the threshold.

function checkThreshold(uint256 voteCount) external view returns (bool);

Events

ValidatorAdded

Emitted when a new validator is added.

event ValidatorAdded(address indexed validator);

Parameters

NameTypeDescription
validatoraddressThe validator address to add.

ValidatorRemoved

Emitted when a validator is removed.

event ValidatorRemoved(address indexed validator);

Parameters

NameTypeDescription
validatoraddressThe validator address to remove.

RequirementChanged

Emitted when a new required number is set.

event RequirementChanged(uint256 indexed requirement, uint256 indexed previousRequired);

Parameters

NameTypeDescription
requirementuint256The new required number to set.
previousRequireduint256The previous required number.