Class Governance
- java.lang.Object
-
- com.klaytn.caver.rpc.Governance
-
public class Governance extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected org.web3j.protocol.Web3jService
provider
JSON-RPC service instance.
-
Constructor Summary
Constructors Constructor Description Governance(org.web3j.protocol.Web3jService provider)
Creates a Governance instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.web3j.protocol.core.Request<?,GovernanceChainConfig>
getChainConfig()
Provides the latest chain configurationorg.web3j.protocol.core.Request<?,GovernanceChainConfig>
getChainConfig(java.lang.String blockTag)
Provides the chain configuration by block tag (latest, earliest, pending)org.web3j.protocol.core.Request<?,GovernanceChainConfig>
getChainConfig(java.math.BigInteger blockNumber)
Provides the chain configuration at the specified block numberorg.web3j.protocol.core.Request<?,GovernanceChainConfig>
getChainConfig(org.web3j.protocol.core.DefaultBlockParameter blockNumberOrTag)
org.web3j.protocol.core.Request<?,GovernanceChainConfig>
getChainConfig(org.web3j.protocol.core.DefaultBlockParameterName blockTag)
Provides the chain configuration by block tag (latest, earliest, pending)org.web3j.protocol.core.Request<?,GovernanceChainConfig>
getChainConfigAt(java.lang.String blockTag)
Provides the chain configuration by block tag (latest, earliest, pending)org.web3j.protocol.core.Request<?,GovernanceChainConfig>
getChainConfigAt(java.math.BigInteger blockNumber)
Provides the chain configuration at the specified block numberorg.web3j.protocol.core.Request<?,GovernanceChainConfig>
getChainConfigAt(org.web3j.protocol.core.DefaultBlockParameter blockNumberOrTag)
return chain configurationorg.web3j.protocol.core.Request<?,GovernanceIdxCache>
getIdxCache()
Returns an array of current idxCache in the memory cache.org.web3j.protocol.core.Request<?,GovernanceIdxCache>
getIdxCacheFromDb()
Returns an array that contains all block numbers on which a governance change ever happened.org.web3j.protocol.core.Request<?,GovernanceItems>
getItemCacheFromDb(java.math.BigInteger blockNumber)
Returns the governance information stored in the given block.org.web3j.protocol.core.Request<?,GovernanceItems>
getItemsAt()
Returns governance items at specific block.org.web3j.protocol.core.Request<?,GovernanceItems>
getItemsAt(java.lang.String blockTag)
Returns governance items at specific block.org.web3j.protocol.core.Request<?,GovernanceItems>
getItemsAt(java.math.BigInteger blockNumber)
Returns governance items at specific block.org.web3j.protocol.core.Request<?,GovernanceItems>
getItemsAt(org.web3j.protocol.core.DefaultBlockParameterName blockTag)
Returns governance items at specific block.org.web3j.protocol.core.Request<?,GovernanceMyVotes>
getMyVotes()
Provides my vote information in the epoch.org.web3j.protocol.core.Request<?,GovernanceVotingPower>
getMyVotingPower()
Provides the voting power of the node.org.web3j.protocol.core.Request<?,Bytes20>
getNodeAddress()
Provides the address of the node that a user is using.org.web3j.protocol.core.Request<?,GovernanceItems>
getParams()
Returns governance items at specific block.org.web3j.protocol.core.Request<?,GovernanceItems>
getParams(java.lang.String blockTag)
Returns governance items at specific block.org.web3j.protocol.core.Request<?,GovernanceItems>
getParams(java.math.BigInteger blockNumber)
Returns governance items at specific block.org.web3j.protocol.core.Request<?,GovernanceItems>
getParams(org.web3j.protocol.core.DefaultBlockParameterName blockTag)
Returns governance items at specific block.org.web3j.protocol.core.Request<?,GovernanceItems>
getPendingChanges()
Returns the list of items that have received enough number of votes but not yet finalized.org.web3j.protocol.core.Request<?,GovernanceStakingInfo>
getStakingInfo()
The getStakingInfo returns staking information at a specific block.org.web3j.protocol.core.Request<?,GovernanceStakingInfo>
getStakingInfo(java.lang.String blockTag)
Returns staking information at a specific block.org.web3j.protocol.core.Request<?,GovernanceStakingInfo>
getStakingInfo(java.math.BigInteger blockNumber)
Returns staking information at a specific block.org.web3j.protocol.core.Request<?,GovernanceStakingInfo>
getStakingInfo(org.web3j.protocol.core.DefaultBlockParameterName blockTag)
Returns staking information at a specific block.org.web3j.protocol.core.Request<?,GovernanceVotingPower>
getTotalVotingPower()
Provides the sum of all voting power that CNs have.org.web3j.protocol.core.Request<?,GovernanceNodeVotes>
getVotes()
Returns the votes from all nodes in the epoch.org.web3j.protocol.core.Request<?,GovernanceTally>
showTally()
Provides the current tally of governance votes.org.web3j.protocol.core.Request<?,Bytes>
vote(IVote.VoteItem key, boolean value)
Submits a new vote.org.web3j.protocol.core.Request<?,Bytes>
vote(IVote.VoteItem key, java.lang.String value)
Submits a new vote.org.web3j.protocol.core.Request<?,Bytes>
vote(IVote.VoteItem key, java.math.BigInteger value)
Submits a new vote.org.web3j.protocol.core.Request<?,Bytes>
vote(java.lang.String key, boolean value)
Submits a new vote.org.web3j.protocol.core.Request<?,Bytes>
vote(java.lang.String key, java.lang.String value)
Submits a new vote.org.web3j.protocol.core.Request<?,Bytes>
vote(java.lang.String key, java.math.BigInteger value)
Submits a new vote.
-
-
-
Method Detail
-
vote
public org.web3j.protocol.core.Request<?,Bytes> vote(IVote.VoteItem key, java.lang.String value)
Submits a new vote.If the node has the right to vote based on governance mode, the vote can be placed. If not, and error message will be returned and the vote will be ignored.
Example :
String value = "single"; Bytes response = caver.rpc.governance.vote(IVote.VoteItem.GOVERNANCE_GOVERNANCE_MODE.getKey(), value);
- Parameters:
key
- The name of the configuration setting to be changed. See theIVote.VoteItem
.value
- The value for each key.- Returns:
- Request<?, Bytes>
-
vote
public org.web3j.protocol.core.Request<?,Bytes> vote(java.lang.String key, java.lang.String value)
Submits a new vote.If the node has the right to vote based on governance mode, the vote can be placed. If not, and error message will be returned and the vote will be ignored.
Example :
String key = "governance.governancemode"; String value = "single"; Bytes response = caver.rpc.governance.vote(key, value);
- Parameters:
key
- The name of the configuration setting to be changed. See theIVote.VoteItem
.value
- The value for each key.- Returns:
- Request<?, Bytes>
-
vote
public org.web3j.protocol.core.Request<?,Bytes> vote(IVote.VoteItem key, java.math.BigInteger value)
Submits a new vote.If the node has the right to vote based on governance mode, the vote can be placed. If not, and error message will be returned and the vote will be ignored.
Example :
BigInteger unitPriceValue = new BigInteger("25000000000"); Bytes response = caver.rpc.governance.vote(IVote.VoteItem.GOVERNANCE_UNIT_PRICE.getKey(), unitPriceValue).send();
- Parameters:
key
- The name of the configuration setting to be changed. See theIVote.VoteItem
.value
- The value for each key.- Returns:
- Bytes
-
vote
public org.web3j.protocol.core.Request<?,Bytes> vote(java.lang.String key, java.math.BigInteger value)
Submits a new vote.If the node has the right to vote based on governance mode, the vote can be placed. If not, and error message will be returned and the vote will be ignored.
Example :
String key = "governance.unitprice"; BigInteger unitPriceValue = new BigInteger("25000000000"); Bytes response = caver.rpc.governance.vote(key, value);
- Parameters:
key
- The name of the configuration setting to be changed. See theIVote.VoteItem
.value
- The value for each key.- Returns:
- Request<?, Bytes>
-
vote
public org.web3j.protocol.core.Request<?,Bytes> vote(IVote.VoteItem key, boolean value)
Submits a new vote.If the node has the right to vote based on governance mode, the vote can be placed. If not, and error message will be returned and the vote will be ignored.
Example :
boolean value = true; Bytes response = caver.rpc.governance.vote(IVote.VoteItem.REWARD_USE_GINICOEFF.getKey(), value).send();
- Parameters:
key
- The name of the configuration setting to be changed. See theIVote.VoteItem
.value
- The value for each key.- Returns:
- Request<?, Bytes>
-
vote
public org.web3j.protocol.core.Request<?,Bytes> vote(java.lang.String key, boolean value)
Submits a new vote.If the node has the right to vote based on governance mode, the vote can be placed. If not, and error message will be returned and the vote will be ignored.
Example :
String key = "reward.useginicoeff"; boolean value = true; Bytes response = caver.rpc.governance.vote(key, value);
- Parameters:
key
- The name of the configuration setting to be changed. See theIVote.VoteItem
.value
- The value for each key.- Returns:
- Request<?, Bytes>
-
showTally
public org.web3j.protocol.core.Request<?,GovernanceTally> showTally()
Provides the current tally of governance votes.It shows the aggregated approval rate in percentage. When it goes over 50%, the vote passed.
Example :
GovernanceTally response = caver.rpc.governance.showTally().send(); GovernanceTally.TallyData item = item.getResult().get(0); float percent = item.getApprovalPercentage(); BigInteger unitPrice = IVote.VoteItem.getUnitPrice(item);
- Returns:
- Request<?, GovernanceTally>
-
getTotalVotingPower
public org.web3j.protocol.core.Request<?,GovernanceVotingPower> getTotalVotingPower()
Provides the sum of all voting power that CNs have. Each CN has 1.0 ~ 2.0 voting power.In "none", "single" governance mode, totalVotingPower don't provide any information.
Example :
GovernanceVotingPower response = caver.rpc.governance.getTotalVotingPower().send();
- Returns:
- Request<?, GovernanceTally>
-
getMyVotingPower
public org.web3j.protocol.core.Request<?,GovernanceVotingPower> getMyVotingPower()
Provides the voting power of the node. The voting power can be 1.0 ~ 2.0.In "none", "single" governance mode, totalVotingPower don't provide any information.
Example :
GovernanceVotingPower response = caver.rpc.governance.getMyVotingPower().send();
- Returns:
- Request<?, GovernanceVotingPower>
-
getMyVotes
public org.web3j.protocol.core.Request<?,GovernanceMyVotes> getMyVotes()
Provides my vote information in the epoch.Each vote is stored in a block when the user's node generates a new block. After current epoch ends, this information is cleared.
Example :
GovernanceMyVotes response = caver.rpc.governance.getMyVotes().send(); List voteList = response.getResult(); GovernanceMyVotes.MyVote myVote = (GovernanceMyVotes.MyVote)voteList.get(0); String mode = IVote.VoteItem.getGovernanceMode(voteList); // passed list. mode = IVote.VoteItem.getGovernanceMode(myVote)); // passed list item.
- Returns:
- Request<?, GovernanceMyVotes>
-
getChainConfig
public org.web3j.protocol.core.Request<?,GovernanceChainConfig> getChainConfig()
Provides the latest chain configurationExample :
GovernanceChainConfig response = caver.rpc.governance.getChainConfig().send();
- Returns:
- Request<?, GovernanceChainConfig>
-
getChainConfig
public org.web3j.protocol.core.Request<?,GovernanceChainConfig> getChainConfig(java.math.BigInteger blockNumber)
Provides the chain configuration at the specified block numberExample :
GovernanceChainConfig response = caver.rpc.governance.getChainConfig(BigInteger.ZERO).send();
- Returns:
- Request<?, GovernanceChainConfig>
-
getChainConfig
public org.web3j.protocol.core.Request<?,GovernanceChainConfig> getChainConfig(java.lang.String blockTag)
Provides the chain configuration by block tag (latest, earliest, pending)Example :
GovernanceChainConfig response = caver.rpc.governance.getChainConfig("latest").send();
- Returns:
- Request<?, GovernanceChainConfig>
-
getChainConfig
public org.web3j.protocol.core.Request<?,GovernanceChainConfig> getChainConfig(org.web3j.protocol.core.DefaultBlockParameterName blockTag)
Provides the chain configuration by block tag (latest, earliest, pending)Example :
GovernanceChainConfig response = caver.rpc.governance.getChainConfig(DefaultBlockParameterName.LATEST).send(); String mode = IVote.VoteItem.getGovernanceMode(governanceItem);
- Returns:
- Request<?, GovernanceChainConfig>
-
getChainConfig
public org.web3j.protocol.core.Request<?,GovernanceChainConfig> getChainConfig(org.web3j.protocol.core.DefaultBlockParameter blockNumberOrTag)
-
getChainConfigAt
public org.web3j.protocol.core.Request<?,GovernanceChainConfig> getChainConfigAt(java.math.BigInteger blockNumber)
Provides the chain configuration at the specified block numberExample :
GovernanceChainConfig response = caver.rpc.governance.getChainConfigAt(BigInteger.ZERO).send();
- Returns:
- Request<?, GovernanceChainConfig>
-
getChainConfigAt
public org.web3j.protocol.core.Request<?,GovernanceChainConfig> getChainConfigAt(java.lang.String blockTag)
Provides the chain configuration by block tag (latest, earliest, pending)Example :
GovernanceChainConfig response = caver.rpc.governance.getChainConfigAt("latest").send();
- Returns:
- Request<?, GovernanceChainConfig>
-
getChainConfigAt
public org.web3j.protocol.core.Request<?,GovernanceChainConfig> getChainConfigAt(org.web3j.protocol.core.DefaultBlockParameter blockNumberOrTag)
return chain configuration
-
getNodeAddress
public org.web3j.protocol.core.Request<?,Bytes20> getNodeAddress()
Provides the address of the node that a user is using.It is derived from the nodekey and used to sign consensus messages. And the value of "governingnode" has to be one of validator's node address.
Example :
Bytes20 response = caver.rpc.governance.getNodeAddress().send();
- Returns:
- Request<?, Bytes20>
-
getParams
public org.web3j.protocol.core.Request<?,GovernanceItems> getParams()
Returns governance items at specific block.It is the result of previous voting of the block and used as configuration for chain at the given block number.
It pass the latest block tag as a parameter.
Example :
GovernanceItems response = caver.rpc.governance.getParams().send(); Map<String, Object> governanceItem = response.getResult(); String mode = IVote.VoteItem.getGovernanceMode(governanceItem);
- Returns:
- Request<?, Bytes20>
-
getParams
public org.web3j.protocol.core.Request<?,GovernanceItems> getParams(java.math.BigInteger blockNumber)
Returns governance items at specific block.It is the result of previous voting of the block and used as configuration for chain at the given block number.
Example :
GovernanceItems response = caver.rpc.governance.getParams(BigInteger.ZERO).send(); Map<String, Object> governanceItem = response.getResult(); String mode = IVote.VoteItem.getGovernanceMode(governanceItem);
- Parameters:
blockNumber
- The block number to query.- Returns:
- Request<?, GovernanceItems>
-
getParams
public org.web3j.protocol.core.Request<?,GovernanceItems> getParams(java.lang.String blockTag)
Returns governance items at specific block.It is the result of previous voting of the block and used as configuration for chain at the given block number.
Example :
GovernanceItems response = caver.rpc.governance.getParams("latest").send(); Map<String, Object> governanceItem = response.getResult(); String mode = IVote.VoteItem.getGovernanceMode(governanceItem);
- Parameters:
blockTag
- The block tag to query- Returns:
- Request<?, GovernanceItems>
-
getParams
public org.web3j.protocol.core.Request<?,GovernanceItems> getParams(org.web3j.protocol.core.DefaultBlockParameterName blockTag)
Returns governance items at specific block.It is the result of previous voting of the block and used as configuration for chain at the given block number.
Example :
GovernanceItems response = caver.rpc.governance.getParams(DefaultBlockParameterName.LATEST).send(); Map<String, Object> governanceItem = response.getResult(); String mode = IVote.VoteItem.getGovernanceMode(governanceItem);
- Parameters:
blockTag
- The block tag to query- Returns:
- Request<?, GovernanceItems>
-
getItemsAt
public org.web3j.protocol.core.Request<?,GovernanceItems> getItemsAt()
Returns governance items at specific block.It is the result of previous voting of the block and used as configuration for chain at the given block number.
It pass the latest block tag as a parameter.
Example :
GovernanceItems response = caver.rpc.governance.getItemsAt().send(); Map<String, Object> governanceItem = response.getResult(); String mode = IVote.VoteItem.getGovernanceMode(governanceItem);
- Returns:
- Request<?, Bytes20>
-
getItemsAt
public org.web3j.protocol.core.Request<?,GovernanceItems> getItemsAt(java.math.BigInteger blockNumber)
Returns governance items at specific block.It is the result of previous voting of the block and used as configuration for chain at the given block number.
Example :
GovernanceItems response = caver.rpc.governance.getItemsAt(BigInteger.ZERO).send(); Map<String, Object> governanceItem = response.getResult(); String mode = IVote.VoteItem.getGovernanceMode(governanceItem);
- Parameters:
blockNumber
- The block number to query.- Returns:
- Request<?, GovernanceItems>
-
getItemsAt
public org.web3j.protocol.core.Request<?,GovernanceItems> getItemsAt(java.lang.String blockTag)
Returns governance items at specific block.It is the result of previous voting of the block and used as configuration for chain at the given block number.
Example :
GovernanceItems response = caver.rpc.governance.getItemsAt("latest").send(); Map<String, Object> governanceItem = response.getResult(); String mode = IVote.VoteItem.getGovernanceMode(governanceItem);
- Parameters:
blockTag
- The block tag to query- Returns:
- Request<?, GovernanceItems>
-
getItemsAt
public org.web3j.protocol.core.Request<?,GovernanceItems> getItemsAt(org.web3j.protocol.core.DefaultBlockParameterName blockTag)
Returns governance items at specific block.It is the result of previous voting of the block and used as configuration for chain at the given block number.
Example :
GovernanceItems response = caver.rpc.governance.getItemsAt(DefaultBlockParameterName.LATEST).send(); Map<String, Object> governanceItem = response.getResult(); String mode = IVote.VoteItem.getGovernanceMode(governanceItem);
- Parameters:
blockTag
- The block tag to query- Returns:
- Request<?, GovernanceItems>
-
getPendingChanges
public org.web3j.protocol.core.Request<?,GovernanceItems> getPendingChanges()
Returns the list of items that have received enough number of votes but not yet finalized.At the end of the current epoch, these changes will be finalized and the result will be in effect from the epoch after next epoch.
Example :
GovernanceItems response = caver.rpc.governance.getPendingChanges().send(); Map<String, Object> governanceItem = response.getResult(); String mode = IVote.VoteItem.getGovernanceMode(governanceItem); mode = governanceItem.get("governance.governancemode");
- Returns:
- Request<?, GovernanceItems>
-
getVotes
public org.web3j.protocol.core.Request<?,GovernanceNodeVotes> getVotes()
Returns the votes from all nodes in the epoch. These votes are gathered from the header of each block.Example :
GovernanceNodeVotes response = caver.rpc.governance.getVotes().send(); List list = response.getResult(); GovernanceNodeVotes.NodeVote item = (GovernanceNodeVotes.NodeVote)list.get(0); BigInteger unitPrice = IVote.VoteItem.getUnitPrice(list); boolean useGini = IVote.VoteItem.toBooleanValue(item.getKey(), item.getValue());
- Returns:
- Request<?, GovernanceItems>
-
getIdxCache
public org.web3j.protocol.core.Request<?,GovernanceIdxCache> getIdxCache()
Returns an array of current idxCache in the memory cache.idxCache contains the block numbers where governance change happened. The cache can have up to 1000 block numbers in memory by default.
Example :
GovernanceIdxCache response = caver.rpc.governance.getIdxCache().send();
- Returns:
- Request<?, GovernanceIdxCache>
-
getIdxCacheFromDb
public org.web3j.protocol.core.Request<?,GovernanceIdxCache> getIdxCacheFromDb()
Returns an array that contains all block numbers on which a governance change ever happened.The result of idxCacheFromDb is the same or longer than that of idxCache.
Example :
GovernanceIdxCache response = caver.rpc.governance.getIdxCacheFromDb().send();
- Returns:
- Request<?, GovernanceIdxCache>
-
getItemCacheFromDb
public org.web3j.protocol.core.Request<?,GovernanceItems> getItemCacheFromDb(java.math.BigInteger blockNumber)
Returns the governance information stored in the given block. If no changes were stored in the given block, the function returns null.Example :
GovernanceItems response = caver.rpc.governance.getItemCacheFromDb(BigInteger.ZERO).send();
- Parameters:
blockNumber
- A block number to query the governance change made in the block.- Returns:
- Request<?, GovernanceItems>
-
getStakingInfo
public org.web3j.protocol.core.Request<?,GovernanceStakingInfo> getStakingInfo()
The getStakingInfo returns staking information at a specific block.It passes the latest block tag as a parameter.
Example :
GovernanceStackingInfo response = caver.rpc.governance.getStakingInfo().send();
- Returns:
- Request<?, GovernanceStackingInfo>
-
getStakingInfo
public org.web3j.protocol.core.Request<?,GovernanceStakingInfo> getStakingInfo(java.math.BigInteger blockNumber)
Returns staking information at a specific block.Example :
GovernanceStackingInfo response = caver.rpc.governance.getStakingInfo(BigInteger.ZERO).send();
- Parameters:
blockNumber
- The block number.- Returns:
- Request<?, GovernanceStackingInfo>
-
getStakingInfo
public org.web3j.protocol.core.Request<?,GovernanceStakingInfo> getStakingInfo(java.lang.String blockTag)
Returns staking information at a specific block.Example :
GovernanceStackingInfo response = caver.rpc.governance.getStakingInfo("latest").send();
- Parameters:
blockTag
- The block tag.- Returns:
- Request<?, GovernanceStackingInfo>
-
getStakingInfo
public org.web3j.protocol.core.Request<?,GovernanceStakingInfo> getStakingInfo(org.web3j.protocol.core.DefaultBlockParameterName blockTag)
Returns staking information at a specific block.Example :
GovernanceStackingInfo response = caver.rpc.governance.getStakingInfo(DefaultBlockParameterName.LATEST).send();
- Parameters:
blockTag
- The block tag.- Returns:
- Request<?, GovernanceStackingInfo>
-
-