aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei-Ning Huang <w@cobinhood.com>2018-10-11 10:57:44 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:23:38 +0800
commitb30675ce058e2c0b4f06a1e814eea7ac9c165555 (patch)
treeb487962931c7b5dbd535213b399aa3c982451d3b
parent03f0a6a6a140d2286300e821cbca8b049b3fcec7 (diff)
downloadgo-tangerine-b30675ce058e2c0b4f06a1e814eea7ac9c165555.tar
go-tangerine-b30675ce058e2c0b4f06a1e814eea7ac9c165555.tar.gz
go-tangerine-b30675ce058e2c0b4f06a1e814eea7ac9c165555.tar.bz2
go-tangerine-b30675ce058e2c0b4f06a1e814eea7ac9c165555.tar.lz
go-tangerine-b30675ce058e2c0b4f06a1e814eea7ac9c165555.tar.xz
go-tangerine-b30675ce058e2c0b4f06a1e814eea7ac9c165555.tar.zst
go-tangerine-b30675ce058e2c0b4f06a1e814eea7ac9c165555.zip
core: vm: expose nodes as public
-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 {