aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm
diff options
context:
space:
mode:
authorWei-Ning Huang <w@cobinhood.com>2018-10-11 10:57:44 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:49 +0800
commitbfb2740f4d72ebb2116b72f7acfcebfe1cee6560 (patch)
tree4aefb19e7abd05ccbd1a4a59be76316fae60a80b /core/vm
parenta05421f63e5abe32ee69b82ac25b3f1925b90e2a (diff)
downloaddexon-bfb2740f4d72ebb2116b72f7acfcebfe1cee6560.tar
dexon-bfb2740f4d72ebb2116b72f7acfcebfe1cee6560.tar.gz
dexon-bfb2740f4d72ebb2116b72f7acfcebfe1cee6560.tar.bz2
dexon-bfb2740f4d72ebb2116b72f7acfcebfe1cee6560.tar.lz
dexon-bfb2740f4d72ebb2116b72f7acfcebfe1cee6560.tar.xz
dexon-bfb2740f4d72ebb2116b72f7acfcebfe1cee6560.tar.zst
dexon-bfb2740f4d72ebb2116b72f7acfcebfe1cee6560.zip
core: vm: expose nodes as public
Diffstat (limited to 'core/vm')
-rw-r--r--core/vm/governance.go66
1 files changed, 52 insertions, 14 deletions
diff --git a/core/vm/governance.go b/core/vm/governance.go
index a60e99b95..e4c3b31e3 100644
--- a/core/vm/governance.go
+++ b/core/vm/governance.go
@@ -74,6 +74,33 @@ const abiJSON = `
},
{
"constant": true,
+ "inputs": [
+ {
+ "name": "",
+ "type": "uint256"
+ }
+ ],
+ "name": "nodes",
+ "outputs": [
+ {
+ "name": "owner",
+ "type": "address"
+ },
+ {
+ "name": "publicKey",
+ "type": "bytes"
+ },
+ {
+ "name": "staked",
+ "type": "uint256"
+ }
+ ],
+ "payable": false,
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "constant": true,
"inputs": [],
"name": "lambdaBA",
"outputs": [
@@ -581,6 +608,16 @@ func RunGovernanceContract(evm *EVM, input []byte, contract *Contract) (
// Solidity auto generated methods.
// --------------------------------
+ case "crs":
+ round := new(big.Int)
+ if err := method.Inputs.Unpack(&round, arguments); err != nil {
+ return nil, errExecutionReverted
+ }
+ res, err := method.Outputs.Pack(g.state.crs(round))
+ if err != nil {
+ return nil, errExecutionReverted
+ }
+ return res, nil
case "dkgComplaints":
round, index := new(big.Int), new(big.Int)
args := []interface{}{&round, &index}
@@ -636,18 +673,8 @@ func RunGovernanceContract(evm *EVM, input []byte, contract *Contract) (
return nil, errExecutionReverted
}
return res, nil
- case "crs":
- round := new(big.Int)
- if err := method.Inputs.Unpack(&round, arguments); err != nil {
- return nil, errExecutionReverted
- }
- res, err := method.Outputs.Pack(g.state.crs(round))
- if err != nil {
- return nil, errExecutionReverted
- }
- return res, nil
- case "owner":
- res, err := method.Outputs.Pack(g.state.owner())
+ case "dkgSetSize":
+ res, err := method.Outputs.Pack(g.state.dkgSetSize())
if err != nil {
return nil, errExecutionReverted
}
@@ -688,8 +715,13 @@ func RunGovernanceContract(evm *EVM, input []byte, contract *Contract) (
return nil, errExecutionReverted
}
return res, nil
- case "dkgSetSize":
- res, err := method.Outputs.Pack(g.state.dkgSetSize())
+ case "nodes":
+ index := new(big.Int)
+ if err := method.Inputs.Unpack(&index, arguments); err != nil {
+ return nil, errExecutionReverted
+ }
+ info := g.state.node(index)
+ res, err := method.Outputs.Pack(info.owner, info.publicKey, info.staked)
if err != nil {
return nil, errExecutionReverted
}
@@ -710,6 +742,12 @@ func RunGovernanceContract(evm *EVM, input []byte, contract *Contract) (
return nil, errExecutionReverted
}
return res, nil
+ case "owner":
+ res, err := method.Outputs.Pack(g.state.owner())
+ if err != nil {
+ return nil, errExecutionReverted
+ }
+ return res, nil
case "phiRatio":
res, err := method.Outputs.Pack(g.state.phiRatio())
if err != nil {