Skip to content

IPChainVotePower#

Interface for the vote power part of the PChainStakeMirror contract.

Events#

VotePowerCacheCreated#

Defined in IPChainVotePower (Docs, Source).

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#

Defined in IPChainVotePower (Docs, Source).

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)ischangedfrompriorVotePowertonewVotePower`.

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#

Defined in IPChainVotePower (Docs, Source).

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#

Defined in IPChainVotePower (Docs, Source).

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#

Defined in IPChainVotePower (Docs, Source).

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#

Defined in IPChainVotePower (Docs, Source).

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#

Defined in IPChainVotePower (Docs, Source).

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#

Defined in IPChainVotePower (Docs, Source).

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#

Defined in IPChainVotePower (Docs, Source).

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#

Defined in IPChainVotePower (Docs, Source).

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#

Defined in IPChainVotePower (Docs, Source).

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#

Defined in IPChainVotePower (Docs, Source).

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#

Defined in IPChainVotePower (Docs, Source).

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.