Skip to content

Latest commit

 

History

History
424 lines (352 loc) · 10.8 KB

pos.md

File metadata and controls

424 lines (352 loc) · 10.8 KB

Classes

PoS

Class contains pos RPC methods For the detail meaning of fields, please refer to the PoS RPC document:

Typedefs

PivotDecision : Object
PoSStatus : Object

PoS status

VotePowerState : Object
PoSAccountStatus : Object
PoSAccount : Object
PoSTransaction : Object
Signature : Object
PoSBlock : Object
CommitteeNode : Object
Election : Object
CurrentCommittee : Object
PoSCommittee : Object
PoSReward : Object
PoSEpochRewards : Object

PoS

Class contains pos RPC methods For the detail meaning of fields, please refer to the PoS RPC document:

Kind: global class

new PoS(conflux)

Create PoS instance

Returns: PoS - The PoS instance

Param Type Description
conflux Conflux The Conflux object

PivotDecision : Object

Kind: global typedef
Properties

Name Type
height number
blockHash string

PoSStatus : Object

PoS status

Kind: global typedef
Properties

Name Type
latestCommitted number
epoch number
latestVoted number
latestTxNumber number
pivotDecision PivotDecision

VotePowerState : Object

Kind: global typedef
Properties

Name Type
endBlockNumber number
power number

PoSAccountStatus : Object

Kind: global typedef
Properties

Name Type
availableVotes number
forfeited number
inQueue Array.<VotePowerState>
outQueue Array.<VotePowerState>
locked number
unlocked number
forceRetired number | null

PoSAccount : Object

Kind: global typedef
Properties

Name Type
blockNumber number
status PoSAccountStatus

PoSTransaction : Object

Kind: global typedef
Properties

Name Type
hash string
blockHash string
from string
status string
type string
number number
timestamp number | null
blockNumber number | null
payload *

Signature : Object

Kind: global typedef
Properties

Name Type
votes number
account string

PoSBlock : Object

Kind: global typedef
Properties

Name Type
epoch number
height number
pivotDecision PivotDecision
round number
timestamp number
lastTxNumber number
signatures Signature

CommitteeNode : Object

Kind: global typedef
Properties

Name Type
votingPower number
address string

Election : Object

Kind: global typedef
Properties

Name Type
isFinalized boolean
startBlockNumber number
topElectingNodes Array.<CommitteeNode>

CurrentCommittee : Object

Kind: global typedef
Properties

Name Type
epochNumber number
quorumVotingPower number
totalVotingPower number
nodes Array.<CommitteeNode>

PoSCommittee : Object

Kind: global typedef
Properties

Name Type
currentCommittee CurrentCommittee
elections Array.<Election>

PoSReward : Object

Kind: global typedef
Properties

Name Type
reward number
posAddress string
powAddress string

PoSEpochRewards : Object

Kind: global typedef
Properties

Name Type
powEpochHash string
accountRewards Array.<PoSReward>

.getStatus ⇒ Promise.<PoSStatus>

Kind: instance member
Returns: Promise.<PoSStatus> - PoS status object
Example

await conflux.pos.getStatus();
// {
//   epoch: 138,
//   latestCommitted: 8235,
//   latestTxNumber: '0xa5e2',
//   latestVoted: 8238,
//   pivotDecision: {
//     blockHash: '0x97625d04ece6fe322ae38010ac877447927b4d5963af7eaea7db9befb615e510',
//     height: 394020
//   }
// }

.getAccount ⇒ Promise.<PoSAccount>

Kind: instance member

Param Type Description
account Hash Account address
[blockNumber] number | hex Optional block number

Example

await conflux.pos.getAccount('0x0f0ccf5ee5276b102316acb3943a2750085f85ac7b94bdbf9d8901f03a7d7cc3');
{
  address: '0x0f0ccf5ee5276b102316acb3943a2750085f85ac7b94bdbf9d8901f03a7d7cc3',
  blockNumber: 8240,
  status: {
    availableVotes: 1525,
    forceRetired: null,
    forfeited: 0,
    inQueue: [],
    locked: 1525,
    outQueue: [],
    unlocked: 1
  }
}

.getBlockByHash ⇒ Promise.<PoSBlock>

Kind: instance member

Param Type Description
hash string The hash of PoS block

Example

await conflux.pos.getBlockByHash('0x97625d04ece6fe322ae38010ac877447927b4d5963af7eaea7db9befb615e510');

.getBlockByNumber ⇒ Promise.<PoSBlock>

Kind: instance member

Param Type Description
blockNumber number | hex The number of PoS block

Example

await conflux.pos.getBlockByNumber(8235);
{
  epoch: 138,
  hash: '0x1daf5443b7556cc39c3d4fe5e208fa77c3f5c053ea4bd637f5e43dfa7f0a95cb',
  height: 8235,
  miner: '0x0f0ccf5ee5276b102316acb3943a2750085f85ac7b94bdbf9d8901f03a7d7cc3',
  lastTxNumber: 42467,
  parentHash: '0x308699b307c81906ab97cbf213532c196f2d718f4641266aa444209349d9e31c',
  pivotDecision: {
    blockHash: '0x97625d04ece6fe322ae38010ac877447927b4d5963af7eaea7db9befb615e510',
    height: 394020
  },
  round: 15,
  signatures: [
    {
      account: '0x00f7c03318f8c4a7c6ae432e124b4a0474e973139a87f9ea6ae3efba66af7d8a',
      votes: 3
    }
  ],
  timestamp: 1638340165169041
}

.getCommittee ⇒ Promise.<PoSCommittee>

Kind: instance member

Param Type Description
[blockNumber] number | hex Optional block number

Example

await conflux.pos.getCommittee();
{
  currentCommittee: {
    epochNumber: 138,
    nodes: [
     {
      address: "0xf92d8504fad118ddb5cf475180f5bcffaa967a9f9fa9c3c899ff9ad0de99694a",
      votingPower: 3
     }
    ],
    quorumVotingPower: 199,
    totalVotingPower: 297
  },
  elections: [
    {
      isFinalized: false,
      startBlockNumber: 8280,
      topElectingNodes: [
        {
          address: "0x0f0ccf5ee5276b102316acb3943a2750085f85ac7b94bdbf9d8901f03a7d7cc3",
          votingPower: 3
        }
      ]
    },
    {
      isFinalized: false,
      startBlockNumber: 8340,
      topElectingNodes: []
    }
  ]
}

.getTransactionByNumber ⇒ Promise.<PoSTransaction>

Kind: instance member

Param Type Description
txNumber number | string The number of transaction

Example

await conflux.pos.getTransactionByNumber(8235);
{
  blockHash: '0xe684e88981b7ffe14741a2274e7b65b89ae2e133ebdd783d71ddeeacb4e957d6',
  blockNumber: 8243,
  from: '0x0000000000000000000000000000000000000000000000000000000000000000',
  hash: '0xaa92222b6a20342285ed56de2b77a05a6c1a9a3e4750e4952af8f908f7316b5d',
  number: 42480,
  payload: null,
  status: 'Executed',
  timestamp: 1638340649662468,
  type: 'BlockMetadata'
}

.getRewardsByEpoch(epoch) ⇒ Promise.<PoSEpochRewards>

Kind: instance function

Param Type Description
epoch number | string A PoS epoch number

Example

await conflux.pos.getRewardsByEpoch(138);
{
  accountRewards: [
    {
      posAddress: '0x83ca56dd7b9d1222fff48565ed0261f42a17099061d905f9e743f89574dbd8e0',
      powAddress: 'NET8888:TYPE.USER:AAKFSH1RUYS4P040J5M7DJRJBGMX9ZV7HAJTFN2DKP',
      reward: 605265415757735647n
    },
    ... 122 more items
  ],
  powEpochHash: '0xd634c0a71c6197a6fad9f80439b31b4c7191b3ee42335b1548dad1160f7f628c'
}