IPChainVotePower
Events
VotePowerCacheCreated
event VotePowerCacheCreated (
bytes20 nodeId,
uint256 blockNumber
)
Emitted when a vote power cache entry is created.
Allows history cleaners to track vote power cache cleanup opportunities off-chain.
Parameters
Type
Description
nodeId
bytes20
The node id whose vote power has just been cached.
blockNumber
uint256
The block number at which the vote power has been cached.
VotePowerChanged
event VotePowerChanged (
address owner ,
bytes20 nodeId,
uint256 priorVotePower ,
uint256 newVotePower
)
Event triggered when a stake is confirmed or at the time it ends.
Definition: votePowerFromTo
(owner, nodeId)is
changedfrom
priorVotePowerto
newVotePower`.
Parameters
Type
Description
owner
address
The account that has changed the amount of vote power it is staking.
nodeId
bytes20
The node id whose received vote power has changed.
priorVotePower
uint256
The vote power originally on that node id.
newVotePower
uint256
The new vote power that triggered this event.
Functions
batchVotePowerOfAt
function batchVotePowerOfAt (
bytes20[] _nodeIds,
uint256 _blockNumber
) external view returns (
uint256 []);
Return vote powers for several node ids in a batch.
Parameters
Type
Description
_nodeIds
bytes20[]
The list of node ids to fetch vote power of.
_blockNumber
uint256
The block number at which to fetch.
Returns
Type
Description
[0]
uint256[]
A list of vote powers.
stakesOf
function stakesOf (
address _owner
) external view returns (
bytes20[] _nodeIds,
uint256 [] _amounts);
Get the amounts and node ids being staked to by a vote power owner.
Parameters
Type
Description
_owner
address
The address being queried.
Returns
Type
Description
_nodeIds
bytes20[]
Array of node ids.
_amounts
uint256[]
Array of staked amounts, for each node id.
stakesOfAt
function stakesOfAt (
address _owner ,
uint256 _blockNumber
) external view returns (
bytes20[] _nodeIds,
uint256 [] _amounts);
Get the amounts and node ids being staked to by a vote power owner,
at a given block.
Parameters
Type
Description
_owner
address
The address being queried.
_blockNumber
uint256
The block number being queried.
Returns
Type
Description
_nodeIds
bytes20[]
Array of node ids.
_amounts
uint256[]
Array of staked amounts, for each node id.
totalVotePower
function totalVotePower (
) external view returns (
uint256 );
Get the current total vote power.
Returns
Type
Description
[0]
uint256
The current total vote power (sum of all accounts' vote powers).
totalVotePowerAt
function totalVotePowerAt (
uint256 _blockNumber
) external view returns (
uint256 );
Get the total vote power at block _blockNumber
Parameters
Type
Description
_blockNumber
uint256
The block number at which to fetch.
Returns
Type
Description
[0]
uint256
The total vote power at the block (sum of all accounts' vote powers).
totalVotePowerAtCached
function totalVotePowerAtCached (
uint256 _blockNumber
) external returns (
uint256 );
Get the total vote power at block _blockNumber
using cache.
It tries to read the cached value and if not found, reads the actual value and stores it in cache.
Can only be used if _blockNumber
is in the past, otherwise reverts.
Parameters
Type
Description
_blockNumber
uint256
The block number at which to fetch.
Returns
Type
Description
[0]
uint256
The total vote power at the block (sum of all accounts' vote powers).
votePowerFromTo
function votePowerFromTo (
address _owner ,
bytes20 _nodeId
) external view returns (
uint256 );
Get current staked vote power from _owner
staked to _nodeId
.
Parameters
Type
Description
_owner
address
Address of vote power owner.
_nodeId
bytes20
Node id.
Returns
Type
Description
[0]
uint256
The staked vote power.
votePowerFromToAt
function votePowerFromToAt (
address _owner ,
bytes20 _nodeId,
uint256 _blockNumber
) external view returns (
uint256 );
Get current staked vote power from _owner
staked to _nodeId
at _blockNumber
.
Parameters
Type
Description
_owner
address
Address of vote power owner.
_nodeId
bytes20
Node id.
_blockNumber
uint256
The block number at which to fetch.
Returns
Type
Description
[0]
uint256
The staked vote power.
votePowerOf
function votePowerOf (
bytes20 _nodeId
) external view returns (
uint256 );
Get the current vote power of _nodeId
.
Parameters
Type
Description
_nodeId
bytes20
The node id to get voting power.
Returns
Type
Description
[0]
uint256
Current vote power of _nodeId
.
votePowerOfAt
function votePowerOfAt (
bytes20 _nodeId,
uint256 _blockNumber
) external view returns (
uint256 );
Get the vote power of _nodeId
at block _blockNumber
Parameters
Type
Description
_nodeId
bytes20
The node id to get voting power.
_blockNumber
uint256
The block number at which to fetch.
Returns
Type
Description
[0]
uint256
Vote power of _nodeId
at _blockNumber
.
votePowerOfAtCached
function votePowerOfAtCached (
bytes20 _owner,
uint256 _blockNumber
) external returns (
uint256 );
Get the vote power of _owner
at block _blockNumber
using cache.
It tries to read the cached value and if not found, reads the actual value and stores it in cache.
Can only be used if _blockNumber is in the past, otherwise reverts.
Parameters
Type
Description
_owner
bytes20
The node id to get voting power.
_blockNumber
uint256
The block number at which to fetch.
Returns
Type
Description
[0]
uint256
Vote power of _owner
at _blockNumber
.