From 63c3099d867e9c343d5056fe3c24dc1c3187a5d1 Mon Sep 17 00:00:00 2001 From: zhi Date: Fri, 30 Sep 2022 15:11:07 -0700 Subject: [PATCH] add agent contract support --- Makefile | 2 +- contract/abigen.sh | 3 +- contract/agent.abi | 251 +++++ contract/agent.go | 516 +++++++++ contract/broker.go | 10 + contract/clerk.go | 3 + contract/iotx.go | 5 + contract/pyggstaking.go | 8 + contract/register.go | 3 + contract/rotatablevps.go | 4 + contract/staking.go | 8 + contract/vita.go | 8 + go.mod | 1 + go.sum | 42 +- pb/api/api.pb.go | 1786 +++++++++++++++++------------- pb/api/api.proto | 13 +- pb/api/api_grpc.pb.go | 366 ++++++ server/dummy_server.go | 38 +- server/dummy_server_test.go | 2 +- server/server.go | 45 +- server/servermix.go | 37 +- votesync/agentcontract.go | 63 ++ votesync/brokercontract.go | 56 + votesync/clerkcontract.go | 31 + votesync/discord.go | 43 + votesync/iotexclient.go | 53 + votesync/rotatableweightedvps.go | 144 +++ votesync/vitacontract.go | 74 ++ votesync/votefetcher.go | 153 +++ votesync/votesync.go | 545 +++------ votesync/votesync_test.go | 2 +- votesync/votingpowerstats.go | 35 + 32 files changed, 3106 insertions(+), 1244 deletions(-) create mode 100644 contract/agent.abi create mode 100644 contract/agent.go create mode 100644 pb/api/api_grpc.pb.go create mode 100644 votesync/agentcontract.go create mode 100644 votesync/brokercontract.go create mode 100644 votesync/clerkcontract.go create mode 100644 votesync/discord.go create mode 100644 votesync/iotexclient.go create mode 100644 votesync/rotatableweightedvps.go create mode 100644 votesync/vitacontract.go create mode 100644 votesync/votefetcher.go create mode 100644 votesync/votingpowerstats.go diff --git a/Makefile b/Makefile index 3698ba5..01d1ce2 100644 --- a/Makefile +++ b/Makefile @@ -53,4 +53,4 @@ run: .PHONY: docker docker: - $(DOCKERCMD) build -t $(USER)/iotex-election:latest . \ No newline at end of file + $(DOCKERCMD) build -t $(USER)/iotex-election:latest . diff --git a/contract/abigen.sh b/contract/abigen.sh index 0350496..8d9bf94 100755 --- a/contract/abigen.sh +++ b/contract/abigen.sh @@ -7,4 +7,5 @@ abigen --abi clerk.abi --pkg contract --type Clerk --out clerk.go abigen --abi vita.abi --pkg contract --type Vita --out vita.go abigen --abi register.abi --pkg contract --type Register --out register.go abigen --abi staking.abi --pkg contract --type Staking --out staking.go -abigen --abi pyggstaking.abi --pkg contract --type PyggStaking --out pyggstaking.go \ No newline at end of file +abigen --abi pyggstaking.abi --pkg contract --type PyggStaking --out pyggstaking.go +abigen --abi agent.abi --pkg contract --type Agent --out agent.go \ No newline at end of file diff --git a/contract/agent.abi b/contract/agent.abi new file mode 100644 index 0000000..0817506 --- /dev/null +++ b/contract/agent.abi @@ -0,0 +1,251 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "_vita", + "type": "address" + }, + { + "internalType": "address", + "name": "_notary", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "AUTHENTICATION_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "EIP712DOMAIN_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "_v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "_r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "_s", + "type": "bytes32" + } + ], + "name": "claim", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "_v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "_r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "_s", + "type": "bytes32" + } + ], + "name": "claimFor", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "claimVita", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "claimed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "wallet", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "digest", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "lastClaimCycles", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "notary", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "poolSize", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "vita", + "outputs": [ + { + "internalType": "contract Vita", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } +] \ No newline at end of file diff --git a/contract/agent.go b/contract/agent.go new file mode 100644 index 0000000..8182640 --- /dev/null +++ b/contract/agent.go @@ -0,0 +1,516 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package contract + +import ( + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription +) + +// AgentABI is the input ABI used to generate the binding from. +const AgentABI = "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_vita\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_notary\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"AUTHENTICATION_TYPEHASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"DOMAIN_SEPARATOR\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"EIP712DOMAIN_TYPEHASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"_v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"_r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_s\",\"type\":\"bytes32\"}],\"name\":\"claim\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_owner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"_v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"_r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_s\",\"type\":\"bytes32\"}],\"name\":\"claimFor\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"claimVita\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"}],\"name\":\"claimed\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"wallet\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"}],\"name\":\"digest\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"lastClaimCycles\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"notary\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"poolSize\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"vita\",\"outputs\":[{\"internalType\":\"contractVita\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]" + +// Agent is an auto generated Go binding around an Ethereum contract. +type Agent struct { + AgentCaller // Read-only binding to the contract + AgentTransactor // Write-only binding to the contract + AgentFilterer // Log filterer for contract events +} + +// AgentCaller is an auto generated read-only Go binding around an Ethereum contract. +type AgentCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// AgentTransactor is an auto generated write-only Go binding around an Ethereum contract. +type AgentTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// AgentFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type AgentFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// AgentSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type AgentSession struct { + Contract *Agent // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// AgentCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type AgentCallerSession struct { + Contract *AgentCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// AgentTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type AgentTransactorSession struct { + Contract *AgentTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// AgentRaw is an auto generated low-level Go binding around an Ethereum contract. +type AgentRaw struct { + Contract *Agent // Generic contract binding to access the raw methods on +} + +// AgentCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type AgentCallerRaw struct { + Contract *AgentCaller // Generic read-only contract binding to access the raw methods on +} + +// AgentTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type AgentTransactorRaw struct { + Contract *AgentTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewAgent creates a new instance of Agent, bound to a specific deployed contract. +func NewAgent(address common.Address, backend bind.ContractBackend) (*Agent, error) { + contract, err := bindAgent(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &Agent{AgentCaller: AgentCaller{contract: contract}, AgentTransactor: AgentTransactor{contract: contract}, AgentFilterer: AgentFilterer{contract: contract}}, nil +} + +// NewAgentCaller creates a new read-only instance of Agent, bound to a specific deployed contract. +func NewAgentCaller(address common.Address, caller bind.ContractCaller) (*AgentCaller, error) { + contract, err := bindAgent(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &AgentCaller{contract: contract}, nil +} + +// NewAgentTransactor creates a new write-only instance of Agent, bound to a specific deployed contract. +func NewAgentTransactor(address common.Address, transactor bind.ContractTransactor) (*AgentTransactor, error) { + contract, err := bindAgent(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &AgentTransactor{contract: contract}, nil +} + +// NewAgentFilterer creates a new log filterer instance of Agent, bound to a specific deployed contract. +func NewAgentFilterer(address common.Address, filterer bind.ContractFilterer) (*AgentFilterer, error) { + contract, err := bindAgent(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &AgentFilterer{contract: contract}, nil +} + +// bindAgent binds a generic wrapper to an already deployed contract. +func bindAgent(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(AgentABI)) + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Agent *AgentRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Agent.Contract.AgentCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Agent *AgentRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Agent.Contract.AgentTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Agent *AgentRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Agent.Contract.AgentTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Agent *AgentCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Agent.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Agent *AgentTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Agent.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Agent *AgentTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Agent.Contract.contract.Transact(opts, method, params...) +} + +// AUTHENTICATIONTYPEHASH is a free data retrieval call binding the contract method 0xb2ae7d46. +// +// Solidity: function AUTHENTICATION_TYPEHASH() view returns(bytes32) +func (_Agent *AgentCaller) AUTHENTICATIONTYPEHASH(opts *bind.CallOpts) ([32]byte, error) { + var out []interface{} + err := _Agent.contract.Call(opts, &out, "AUTHENTICATION_TYPEHASH") + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// AUTHENTICATIONTYPEHASH is a free data retrieval call binding the contract method 0xb2ae7d46. +// +// Solidity: function AUTHENTICATION_TYPEHASH() view returns(bytes32) +func (_Agent *AgentSession) AUTHENTICATIONTYPEHASH() ([32]byte, error) { + return _Agent.Contract.AUTHENTICATIONTYPEHASH(&_Agent.CallOpts) +} + +// AUTHENTICATIONTYPEHASH is a free data retrieval call binding the contract method 0xb2ae7d46. +// +// Solidity: function AUTHENTICATION_TYPEHASH() view returns(bytes32) +func (_Agent *AgentCallerSession) AUTHENTICATIONTYPEHASH() ([32]byte, error) { + return _Agent.Contract.AUTHENTICATIONTYPEHASH(&_Agent.CallOpts) +} + +// DOMAINSEPARATOR is a free data retrieval call binding the contract method 0x3644e515. +// +// Solidity: function DOMAIN_SEPARATOR() view returns(bytes32) +func (_Agent *AgentCaller) DOMAINSEPARATOR(opts *bind.CallOpts) ([32]byte, error) { + var out []interface{} + err := _Agent.contract.Call(opts, &out, "DOMAIN_SEPARATOR") + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// DOMAINSEPARATOR is a free data retrieval call binding the contract method 0x3644e515. +// +// Solidity: function DOMAIN_SEPARATOR() view returns(bytes32) +func (_Agent *AgentSession) DOMAINSEPARATOR() ([32]byte, error) { + return _Agent.Contract.DOMAINSEPARATOR(&_Agent.CallOpts) +} + +// DOMAINSEPARATOR is a free data retrieval call binding the contract method 0x3644e515. +// +// Solidity: function DOMAIN_SEPARATOR() view returns(bytes32) +func (_Agent *AgentCallerSession) DOMAINSEPARATOR() ([32]byte, error) { + return _Agent.Contract.DOMAINSEPARATOR(&_Agent.CallOpts) +} + +// EIP712DOMAINTYPEHASH is a free data retrieval call binding the contract method 0xc49f91d3. +// +// Solidity: function EIP712DOMAIN_TYPEHASH() view returns(bytes32) +func (_Agent *AgentCaller) EIP712DOMAINTYPEHASH(opts *bind.CallOpts) ([32]byte, error) { + var out []interface{} + err := _Agent.contract.Call(opts, &out, "EIP712DOMAIN_TYPEHASH") + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// EIP712DOMAINTYPEHASH is a free data retrieval call binding the contract method 0xc49f91d3. +// +// Solidity: function EIP712DOMAIN_TYPEHASH() view returns(bytes32) +func (_Agent *AgentSession) EIP712DOMAINTYPEHASH() ([32]byte, error) { + return _Agent.Contract.EIP712DOMAINTYPEHASH(&_Agent.CallOpts) +} + +// EIP712DOMAINTYPEHASH is a free data retrieval call binding the contract method 0xc49f91d3. +// +// Solidity: function EIP712DOMAIN_TYPEHASH() view returns(bytes32) +func (_Agent *AgentCallerSession) EIP712DOMAINTYPEHASH() ([32]byte, error) { + return _Agent.Contract.EIP712DOMAINTYPEHASH(&_Agent.CallOpts) +} + +// Claimed is a free data retrieval call binding the contract method 0xc884ef83. +// +// Solidity: function claimed(address _user) view returns(uint256, uint256, bool) +func (_Agent *AgentCaller) Claimed(opts *bind.CallOpts, _user common.Address) (*big.Int, *big.Int, bool, error) { + var out []interface{} + err := _Agent.contract.Call(opts, &out, "claimed", _user) + + if err != nil { + return *new(*big.Int), *new(*big.Int), *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + out1 := *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) + out2 := *abi.ConvertType(out[2], new(bool)).(*bool) + + return out0, out1, out2, err + +} + +// Claimed is a free data retrieval call binding the contract method 0xc884ef83. +// +// Solidity: function claimed(address _user) view returns(uint256, uint256, bool) +func (_Agent *AgentSession) Claimed(_user common.Address) (*big.Int, *big.Int, bool, error) { + return _Agent.Contract.Claimed(&_Agent.CallOpts, _user) +} + +// Claimed is a free data retrieval call binding the contract method 0xc884ef83. +// +// Solidity: function claimed(address _user) view returns(uint256, uint256, bool) +func (_Agent *AgentCallerSession) Claimed(_user common.Address) (*big.Int, *big.Int, bool, error) { + return _Agent.Contract.Claimed(&_Agent.CallOpts, _user) +} + +// Digest is a free data retrieval call binding the contract method 0xfe54bd15. +// +// Solidity: function digest(address wallet, uint256 amount, uint256 deadline) view returns(bytes32) +func (_Agent *AgentCaller) Digest(opts *bind.CallOpts, wallet common.Address, amount *big.Int, deadline *big.Int) ([32]byte, error) { + var out []interface{} + err := _Agent.contract.Call(opts, &out, "digest", wallet, amount, deadline) + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// Digest is a free data retrieval call binding the contract method 0xfe54bd15. +// +// Solidity: function digest(address wallet, uint256 amount, uint256 deadline) view returns(bytes32) +func (_Agent *AgentSession) Digest(wallet common.Address, amount *big.Int, deadline *big.Int) ([32]byte, error) { + return _Agent.Contract.Digest(&_Agent.CallOpts, wallet, amount, deadline) +} + +// Digest is a free data retrieval call binding the contract method 0xfe54bd15. +// +// Solidity: function digest(address wallet, uint256 amount, uint256 deadline) view returns(bytes32) +func (_Agent *AgentCallerSession) Digest(wallet common.Address, amount *big.Int, deadline *big.Int) ([32]byte, error) { + return _Agent.Contract.Digest(&_Agent.CallOpts, wallet, amount, deadline) +} + +// LastClaimCycles is a free data retrieval call binding the contract method 0xb1629241. +// +// Solidity: function lastClaimCycles(address ) view returns(uint256) +func (_Agent *AgentCaller) LastClaimCycles(opts *bind.CallOpts, arg0 common.Address) (*big.Int, error) { + var out []interface{} + err := _Agent.contract.Call(opts, &out, "lastClaimCycles", arg0) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// LastClaimCycles is a free data retrieval call binding the contract method 0xb1629241. +// +// Solidity: function lastClaimCycles(address ) view returns(uint256) +func (_Agent *AgentSession) LastClaimCycles(arg0 common.Address) (*big.Int, error) { + return _Agent.Contract.LastClaimCycles(&_Agent.CallOpts, arg0) +} + +// LastClaimCycles is a free data retrieval call binding the contract method 0xb1629241. +// +// Solidity: function lastClaimCycles(address ) view returns(uint256) +func (_Agent *AgentCallerSession) LastClaimCycles(arg0 common.Address) (*big.Int, error) { + return _Agent.Contract.LastClaimCycles(&_Agent.CallOpts, arg0) +} + +// Notary is a free data retrieval call binding the contract method 0x9d54c79d. +// +// Solidity: function notary() view returns(address) +func (_Agent *AgentCaller) Notary(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Agent.contract.Call(opts, &out, "notary") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Notary is a free data retrieval call binding the contract method 0x9d54c79d. +// +// Solidity: function notary() view returns(address) +func (_Agent *AgentSession) Notary() (common.Address, error) { + return _Agent.Contract.Notary(&_Agent.CallOpts) +} + +// Notary is a free data retrieval call binding the contract method 0x9d54c79d. +// +// Solidity: function notary() view returns(address) +func (_Agent *AgentCallerSession) Notary() (common.Address, error) { + return _Agent.Contract.Notary(&_Agent.CallOpts) +} + +// PoolSize is a free data retrieval call binding the contract method 0x4ec18db9. +// +// Solidity: function poolSize() view returns(uint256) +func (_Agent *AgentCaller) PoolSize(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _Agent.contract.Call(opts, &out, "poolSize") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// PoolSize is a free data retrieval call binding the contract method 0x4ec18db9. +// +// Solidity: function poolSize() view returns(uint256) +func (_Agent *AgentSession) PoolSize() (*big.Int, error) { + return _Agent.Contract.PoolSize(&_Agent.CallOpts) +} + +// PoolSize is a free data retrieval call binding the contract method 0x4ec18db9. +// +// Solidity: function poolSize() view returns(uint256) +func (_Agent *AgentCallerSession) PoolSize() (*big.Int, error) { + return _Agent.Contract.PoolSize(&_Agent.CallOpts) +} + +// Vita is a free data retrieval call binding the contract method 0x393d9bb3. +// +// Solidity: function vita() view returns(address) +func (_Agent *AgentCaller) Vita(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Agent.contract.Call(opts, &out, "vita") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Vita is a free data retrieval call binding the contract method 0x393d9bb3. +// +// Solidity: function vita() view returns(address) +func (_Agent *AgentSession) Vita() (common.Address, error) { + return _Agent.Contract.Vita(&_Agent.CallOpts) +} + +// Vita is a free data retrieval call binding the contract method 0x393d9bb3. +// +// Solidity: function vita() view returns(address) +func (_Agent *AgentCallerSession) Vita() (common.Address, error) { + return _Agent.Contract.Vita(&_Agent.CallOpts) +} + +// Claim is a paid mutator transaction binding the contract method 0xfa6b3b53. +// +// Solidity: function claim(uint256 _amount, uint256 _deadline, uint8 _v, bytes32 _r, bytes32 _s) returns() +func (_Agent *AgentTransactor) Claim(opts *bind.TransactOpts, _amount *big.Int, _deadline *big.Int, _v uint8, _r [32]byte, _s [32]byte) (*types.Transaction, error) { + return _Agent.contract.Transact(opts, "claim", _amount, _deadline, _v, _r, _s) +} + +// Claim is a paid mutator transaction binding the contract method 0xfa6b3b53. +// +// Solidity: function claim(uint256 _amount, uint256 _deadline, uint8 _v, bytes32 _r, bytes32 _s) returns() +func (_Agent *AgentSession) Claim(_amount *big.Int, _deadline *big.Int, _v uint8, _r [32]byte, _s [32]byte) (*types.Transaction, error) { + return _Agent.Contract.Claim(&_Agent.TransactOpts, _amount, _deadline, _v, _r, _s) +} + +// Claim is a paid mutator transaction binding the contract method 0xfa6b3b53. +// +// Solidity: function claim(uint256 _amount, uint256 _deadline, uint8 _v, bytes32 _r, bytes32 _s) returns() +func (_Agent *AgentTransactorSession) Claim(_amount *big.Int, _deadline *big.Int, _v uint8, _r [32]byte, _s [32]byte) (*types.Transaction, error) { + return _Agent.Contract.Claim(&_Agent.TransactOpts, _amount, _deadline, _v, _r, _s) +} + +// ClaimFor is a paid mutator transaction binding the contract method 0xa34010a8. +// +// Solidity: function claimFor(address _owner, uint256 _amount, uint256 _deadline, uint8 _v, bytes32 _r, bytes32 _s) returns() +func (_Agent *AgentTransactor) ClaimFor(opts *bind.TransactOpts, _owner common.Address, _amount *big.Int, _deadline *big.Int, _v uint8, _r [32]byte, _s [32]byte) (*types.Transaction, error) { + return _Agent.contract.Transact(opts, "claimFor", _owner, _amount, _deadline, _v, _r, _s) +} + +// ClaimFor is a paid mutator transaction binding the contract method 0xa34010a8. +// +// Solidity: function claimFor(address _owner, uint256 _amount, uint256 _deadline, uint8 _v, bytes32 _r, bytes32 _s) returns() +func (_Agent *AgentSession) ClaimFor(_owner common.Address, _amount *big.Int, _deadline *big.Int, _v uint8, _r [32]byte, _s [32]byte) (*types.Transaction, error) { + return _Agent.Contract.ClaimFor(&_Agent.TransactOpts, _owner, _amount, _deadline, _v, _r, _s) +} + +// ClaimFor is a paid mutator transaction binding the contract method 0xa34010a8. +// +// Solidity: function claimFor(address _owner, uint256 _amount, uint256 _deadline, uint8 _v, bytes32 _r, bytes32 _s) returns() +func (_Agent *AgentTransactorSession) ClaimFor(_owner common.Address, _amount *big.Int, _deadline *big.Int, _v uint8, _r [32]byte, _s [32]byte) (*types.Transaction, error) { + return _Agent.Contract.ClaimFor(&_Agent.TransactOpts, _owner, _amount, _deadline, _v, _r, _s) +} + +// ClaimVita is a paid mutator transaction binding the contract method 0x77a7af06. +// +// Solidity: function claimVita() returns() +func (_Agent *AgentTransactor) ClaimVita(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Agent.contract.Transact(opts, "claimVita") +} + +// ClaimVita is a paid mutator transaction binding the contract method 0x77a7af06. +// +// Solidity: function claimVita() returns() +func (_Agent *AgentSession) ClaimVita() (*types.Transaction, error) { + return _Agent.Contract.ClaimVita(&_Agent.TransactOpts) +} + +// ClaimVita is a paid mutator transaction binding the contract method 0x77a7af06. +// +// Solidity: function claimVita() returns() +func (_Agent *AgentTransactorSession) ClaimVita() (*types.Transaction, error) { + return _Agent.Contract.ClaimVita(&_Agent.TransactOpts) +} diff --git a/contract/broker.go b/contract/broker.go index 2f02b78..672e9cb 100644 --- a/contract/broker.go +++ b/contract/broker.go @@ -822,6 +822,7 @@ func (_Broker *BrokerFilterer) ParseCollateralWithdrawn(log types.Log) (*BrokerC if err := _Broker.contract.UnpackLog(event, "CollateralWithdrawn", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -957,6 +958,7 @@ func (_Broker *BrokerFilterer) ParseNewRound(log types.Log) (*BrokerNewRound, er if err := _Broker.contract.UnpackLog(event, "NewRound", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -1109,6 +1111,7 @@ func (_Broker *BrokerFilterer) ParseOwnershipTransferred(log types.Log) (*Broker if err := _Broker.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -1241,6 +1244,7 @@ func (_Broker *BrokerFilterer) ParsePause(log types.Log) (*BrokerPause, error) { if err := _Broker.contract.UnpackLog(event, "Pause", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -1373,6 +1377,7 @@ func (_Broker *BrokerFilterer) ParseUnpause(log types.Log) (*BrokerUnpause, erro if err := _Broker.contract.UnpackLog(event, "Unpause", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -1526,6 +1531,7 @@ func (_Broker *BrokerFilterer) ParseVitaBidden(log types.Log) (*BrokerVitaBidden if err := _Broker.contract.UnpackLog(event, "VitaBidden", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -1659,6 +1665,7 @@ func (_Broker *BrokerFilterer) ParseVitaBidsSettled(log types.Log) (*BrokerVitaB if err := _Broker.contract.UnpackLog(event, "VitaBidsSettled", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -1813,6 +1820,7 @@ func (_Broker *BrokerFilterer) ParseVitaBought(log types.Log) (*BrokerVitaBought if err := _Broker.contract.UnpackLog(event, "VitaBought", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -1946,6 +1954,7 @@ func (_Broker *BrokerFilterer) ParseWhitelistedAddressAdded(log types.Log) (*Bro if err := _Broker.contract.UnpackLog(event, "WhitelistedAddressAdded", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -2079,5 +2088,6 @@ func (_Broker *BrokerFilterer) ParseWhitelistedAddressRemoved(log types.Log) (*B if err := _Broker.contract.UnpackLog(event, "WhitelistedAddressRemoved", log); err != nil { return nil, err } + event.Raw = log return event, nil } diff --git a/contract/clerk.go b/contract/clerk.go index 308a476..36f7302 100644 --- a/contract/clerk.go +++ b/contract/clerk.go @@ -560,6 +560,7 @@ func (_Clerk *ClerkFilterer) ParseOwnershipTransferred(log types.Log) (*ClerkOwn if err := _Clerk.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -693,6 +694,7 @@ func (_Clerk *ClerkFilterer) ParseWhitelistedAddressAdded(log types.Log) (*Clerk if err := _Clerk.contract.UnpackLog(event, "WhitelistedAddressAdded", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -826,5 +828,6 @@ func (_Clerk *ClerkFilterer) ParseWhitelistedAddressRemoved(log types.Log) (*Cle if err := _Clerk.contract.UnpackLog(event, "WhitelistedAddressRemoved", log); err != nil { return nil, err } + event.Raw = log return event, nil } diff --git a/contract/iotx.go b/contract/iotx.go index 26d590c..08a90fb 100644 --- a/contract/iotx.go +++ b/contract/iotx.go @@ -737,6 +737,7 @@ func (_IOTX *IOTXFilterer) ParseApproval(log types.Log) (*IOTXApproval, error) { if err := _IOTX.contract.UnpackLog(event, "Approval", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -889,6 +890,7 @@ func (_IOTX *IOTXFilterer) ParseOwnershipTransferred(log types.Log) (*IOTXOwners if err := _IOTX.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -1021,6 +1023,7 @@ func (_IOTX *IOTXFilterer) ParsePause(log types.Log) (*IOTXPause, error) { if err := _IOTX.contract.UnpackLog(event, "Pause", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -1174,6 +1177,7 @@ func (_IOTX *IOTXFilterer) ParseTransfer(log types.Log) (*IOTXTransfer, error) { if err := _IOTX.contract.UnpackLog(event, "Transfer", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -1306,5 +1310,6 @@ func (_IOTX *IOTXFilterer) ParseUnpause(log types.Log) (*IOTXUnpause, error) { if err := _IOTX.contract.UnpackLog(event, "Unpause", log); err != nil { return nil, err } + event.Raw = log return event, nil } diff --git a/contract/pyggstaking.go b/contract/pyggstaking.go index 74054ea..77b97fe 100644 --- a/contract/pyggstaking.go +++ b/contract/pyggstaking.go @@ -1240,6 +1240,7 @@ func (_PyggStaking *PyggStakingFilterer) ParsePause(log types.Log) (*PyggStaking if err := _PyggStaking.contract.UnpackLog(event, "Pause", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -1380,6 +1381,7 @@ func (_PyggStaking *PyggStakingFilterer) ParsePyggCreated(log types.Log) (*PyggS if err := _PyggStaking.contract.UnpackLog(event, "PyggCreated", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -1516,6 +1518,7 @@ func (_PyggStaking *PyggStakingFilterer) ParsePyggUnstake(log types.Log) (*PyggS if err := _PyggStaking.contract.UnpackLog(event, "PyggUnstake", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -1656,6 +1659,7 @@ func (_PyggStaking *PyggStakingFilterer) ParsePyggUpdated(log types.Log) (*PyggS if err := _PyggStaking.contract.UnpackLog(event, "PyggUpdated", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -1792,6 +1796,7 @@ func (_PyggStaking *PyggStakingFilterer) ParsePyggWithdraw(log types.Log) (*Pygg if err := _PyggStaking.contract.UnpackLog(event, "PyggWithdraw", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -1924,6 +1929,7 @@ func (_PyggStaking *PyggStakingFilterer) ParseUnpause(log types.Log) (*PyggStaki if err := _PyggStaking.contract.UnpackLog(event, "Unpause", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -2057,6 +2063,7 @@ func (_PyggStaking *PyggStakingFilterer) ParseWhitelistedAddressAdded(log types. if err := _PyggStaking.contract.UnpackLog(event, "WhitelistedAddressAdded", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -2190,5 +2197,6 @@ func (_PyggStaking *PyggStakingFilterer) ParseWhitelistedAddressRemoved(log type if err := _PyggStaking.contract.UnpackLog(event, "WhitelistedAddressRemoved", log); err != nil { return nil, err } + event.Raw = log return event, nil } diff --git a/contract/register.go b/contract/register.go index ffc042d..3f7da0f 100644 --- a/contract/register.go +++ b/contract/register.go @@ -892,6 +892,7 @@ func (_Register *RegisterFilterer) ParsePause(log types.Log) (*RegisterPause, er if err := _Register.contract.UnpackLog(event, "Pause", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -1030,6 +1031,7 @@ func (_Register *RegisterFilterer) ParseRegistered(log types.Log) (*RegisterRegi if err := _Register.contract.UnpackLog(event, "Registered", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -1162,5 +1164,6 @@ func (_Register *RegisterFilterer) ParseUnpause(log types.Log) (*RegisterUnpause if err := _Register.contract.UnpackLog(event, "Unpause", log); err != nil { return nil, err } + event.Raw = log return event, nil } diff --git a/contract/rotatablevps.go b/contract/rotatablevps.go index 8df9e24..dcd94ae 100644 --- a/contract/rotatablevps.go +++ b/contract/rotatablevps.go @@ -839,6 +839,7 @@ func (_RotatableVPS *RotatableVPSFilterer) ParseOwnershipTransferred(log types.L if err := _RotatableVPS.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -973,6 +974,7 @@ func (_RotatableVPS *RotatableVPSFilterer) ParseSetVotingPower(log types.Log) (* if err := _RotatableVPS.contract.UnpackLog(event, "SetVotingPower", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -1106,6 +1108,7 @@ func (_RotatableVPS *RotatableVPSFilterer) ParseWhitelistedAddressAdded(log type if err := _RotatableVPS.contract.UnpackLog(event, "WhitelistedAddressAdded", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -1239,5 +1242,6 @@ func (_RotatableVPS *RotatableVPSFilterer) ParseWhitelistedAddressRemoved(log ty if err := _RotatableVPS.contract.UnpackLog(event, "WhitelistedAddressRemoved", log); err != nil { return nil, err } + event.Raw = log return event, nil } diff --git a/contract/staking.go b/contract/staking.go index cf6d1e5..82e7e9f 100644 --- a/contract/staking.go +++ b/contract/staking.go @@ -1256,6 +1256,7 @@ func (_Staking *StakingFilterer) ParseBucketCreated(log types.Log) (*StakingBuck if err := _Staking.contract.UnpackLog(event, "BucketCreated", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -1392,6 +1393,7 @@ func (_Staking *StakingFilterer) ParseBucketUnstake(log types.Log) (*StakingBuck if err := _Staking.contract.UnpackLog(event, "BucketUnstake", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -1531,6 +1533,7 @@ func (_Staking *StakingFilterer) ParseBucketUpdated(log types.Log) (*StakingBuck if err := _Staking.contract.UnpackLog(event, "BucketUpdated", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -1667,6 +1670,7 @@ func (_Staking *StakingFilterer) ParseBucketWithdraw(log types.Log) (*StakingBuc if err := _Staking.contract.UnpackLog(event, "BucketWithdraw", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -1799,6 +1803,7 @@ func (_Staking *StakingFilterer) ParsePause(log types.Log) (*StakingPause, error if err := _Staking.contract.UnpackLog(event, "Pause", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -1931,6 +1936,7 @@ func (_Staking *StakingFilterer) ParseUnpause(log types.Log) (*StakingUnpause, e if err := _Staking.contract.UnpackLog(event, "Unpause", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -2064,6 +2070,7 @@ func (_Staking *StakingFilterer) ParseWhitelistedAddressAdded(log types.Log) (*S if err := _Staking.contract.UnpackLog(event, "WhitelistedAddressAdded", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -2197,5 +2204,6 @@ func (_Staking *StakingFilterer) ParseWhitelistedAddressRemoved(log types.Log) ( if err := _Staking.contract.UnpackLog(event, "WhitelistedAddressRemoved", log); err != nil { return nil, err } + event.Raw = log return event, nil } diff --git a/contract/vita.go b/contract/vita.go index 374d2b9..1dd4420 100644 --- a/contract/vita.go +++ b/contract/vita.go @@ -1307,6 +1307,7 @@ func (_Vita *VitaFilterer) ParseApproval(log types.Log) (*VitaApproval, error) { if err := _Vita.contract.UnpackLog(event, "Approval", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -1442,6 +1443,7 @@ func (_Vita *VitaFilterer) ParseClaim(log types.Log) (*VitaClaim, error) { if err := _Vita.contract.UnpackLog(event, "Claim", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -1576,6 +1578,7 @@ func (_Vita *VitaFilterer) ParseDecay(log types.Log) (*VitaDecay, error) { if err := _Vita.contract.UnpackLog(event, "Decay", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -1728,6 +1731,7 @@ func (_Vita *VitaFilterer) ParseOwnershipTransferred(log types.Log) (*VitaOwners if err := _Vita.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -1860,6 +1864,7 @@ func (_Vita *VitaFilterer) ParsePause(log types.Log) (*VitaPause, error) { if err := _Vita.contract.UnpackLog(event, "Pause", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -2013,6 +2018,7 @@ func (_Vita *VitaFilterer) ParseTransfer(log types.Log) (*VitaTransfer, error) { if err := _Vita.contract.UnpackLog(event, "Transfer", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -2145,6 +2151,7 @@ func (_Vita *VitaFilterer) ParseUnpause(log types.Log) (*VitaUnpause, error) { if err := _Vita.contract.UnpackLog(event, "Unpause", log); err != nil { return nil, err } + event.Raw = log return event, nil } @@ -2278,5 +2285,6 @@ func (_Vita *VitaFilterer) ParseUpdateView(log types.Log) (*VitaUpdateView, erro if err := _Vita.contract.UnpackLog(event, "UpdateView", log); err != nil { return nil, err } + event.Raw = log return event, nil } diff --git a/go.mod b/go.mod index 5b28330..7c48b6e 100644 --- a/go.mod +++ b/go.mod @@ -31,6 +31,7 @@ require ( go.uber.org/zap v1.10.0 golang.org/x/net v0.0.0-20201021035429-f5854403a974 google.golang.org/grpc v1.33.1 + google.golang.org/protobuf v1.25.0 gopkg.in/yaml.v2 v2.3.0 ) diff --git a/go.sum b/go.sum index 7a76120..28d994d 100644 --- a/go.sum +++ b/go.sum @@ -35,7 +35,6 @@ github.com/aws/aws-sdk-go v1.25.48/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpi github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/btcsuite/btcd v0.0.0-20171128150713-2e60448ffcc6/go.mod h1:Dmm/EzmjnCiweXmzRIAiUWCInVmPgjkzgv5k4tVyXiQ= -github.com/btcsuite/btcd v0.0.0-20190427004231-96897255fd17 h1:m0N5Vg5nP3zEz8TREZpwX3gt4Biw3/8fbIf4A3hO96g= github.com/btcsuite/btcd v0.0.0-20190427004231-96897255fd17/go.mod h1:3J08xEfcugPacsc34/LKRU2yO7YmuT8yt28J8k2+rrI= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btcd v0.21.0-beta h1:At9hIZdJW0s9E/fAz28nrz6AmcNlSVucCH796ZteX1M= @@ -58,7 +57,9 @@ github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= github.com/cespare/cp v1.1.1 h1:nCb6ZLdB7NRaqsm91JtQTAme2SKJzXVsdPIPkyJr1MU= github.com/cespare/cp v1.1.1/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= +github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudflare/cloudflare-go v0.10.2-0.20190916151808-a80f83b9add9/go.mod h1:1MxXX1Ux4x6mqPmjkUgTP1CdXIBXKX7T+Jk9Gxrmx+U= @@ -91,18 +92,15 @@ github.com/fatih/color v1.3.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv github.com/fjl/memsize v0.0.0-20180418122429-ca190fb6ffbc/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= -github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/go-kit/kit v0.8.0 h1:Wz+5lgoB0kkuqLEc6NVmwRknTKP6dTGbSqvhZtBI/j0= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0 h1:wDJmvq38kDhkVxi50ni9ykkdUr1PKgqKOoi01fa0Mdk= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-logfmt/logfmt v0.3.0 h1:8HUsc87TaSWLKwrnumgC8/YconD2fJQsRJAsWaPg2ic= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0 h1:MP4Eh7ZCb31lleYCFuwm0oe4/YGak+5l1vA2NOE80nA= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= @@ -112,15 +110,12 @@ github.com/go-sourcemap/sourcemap v2.1.2+incompatible/go.mod h1:F8jJfvm2KbVjc5Nq github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= @@ -130,18 +125,15 @@ github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrU github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.2-0.20200707131729-196ae77b8a26 h1:lMm2hD9Fy0ynom5+85/pbdkiYcBqM1JWmhpAXLmy0fw= github.com/golang/snappy v0.0.2-0.20200707131729-196ae77b8a26/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= @@ -149,7 +141,6 @@ github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa/go.mod h1:dBl0BpW6 github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1-0.20190629185528-ae1634f6a989 h1:giknQ4mEuDFmmHSrGcbargOuLHQGtywqo4mheITex54= github.com/gorilla/websocket v1.4.1-0.20190629185528-ae1634f6a989/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= @@ -162,7 +153,6 @@ github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+l github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/holiman/uint256 v1.1.1 h1:4JywC80b+/hSfljFlEBLHrrh+CIONLDz9NuFl0af4Mw= github.com/holiman/uint256 v1.1.1/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw= -github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huin/goupnp v1.0.0 h1:wg75sLpL6DZqwHQN6E1Cfk6mtfzS45z8OV+ic+DtHRo= github.com/huin/goupnp v1.0.0/go.mod h1:n9v9KO1tAxYH82qOn+UTIFQDmx5n1Zxd/ClZDMX7Bnc= @@ -172,6 +162,7 @@ github.com/iotexproject/go-ethereum v1.7.4-0.20210604055808-21e763469056 h1:fDKE github.com/iotexproject/go-ethereum v1.7.4-0.20210604055808-21e763469056/go.mod h1:JIfVb6esrqALTExdz9hRYvrP0xBDf6wCncIu1hNwHpM= github.com/iotexproject/go-pkgs v0.1.5-0.20210604060651-be5ee19f2575 h1:hrYlv0bYO/HHc4TWpDXMLI+0nr7bSI0oLsy/7Jjr/zw= github.com/iotexproject/go-pkgs v0.1.5-0.20210604060651-be5ee19f2575/go.mod h1:ttXhcwrtODyh7JozpJlCml09CjP0pcKqTe2B0MbTGc8= +github.com/iotexproject/iotex-address v0.2.4 h1:qrkM+X6Z6Rljto1KH8ZgAUrnzU5AqMqN0OCXcQEauS4= github.com/iotexproject/iotex-address v0.2.4/go.mod h1:K78yPSMB4K7gF/iQ7djT1amph0RBrP3rSkFfH7gNG70= github.com/iotexproject/iotex-antenna-go/v2 v2.5.1-0.20210604061028-2c2056a5bfdb h1:E6fAldFGmbCIEz0/RB0BRogLiRwrOCiUWUx7zWS3kyo= github.com/iotexproject/iotex-antenna-go/v2 v2.5.1-0.20210604061028-2c2056a5bfdb/go.mod h1:NqFzRL8RtA3xfXGpYbs0IY71HDiD6Dh2hD9iYngKLIU= @@ -185,7 +176,6 @@ github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/julienschmidt/httprouter v1.1.1-0.20170430222011-975b5c4c7c21/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/julienschmidt/httprouter v1.2.0 h1:TDTW5Yz1mjftljbcKqRcrYhd4XeOoI98t+9HbQbYf7g= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356 h1:I/yrLt2WilKxlQKCM52clh5rGzTKpVctGT1lH4Dc8Jw= github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU= @@ -225,23 +215,19 @@ github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416/go.mod h1:NBIhNtsFMo github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= -github.com/olekukonko/tablewriter v0.0.1 h1:b3iUnf1v+ppJiOfNX4yxxqfWKMQPZR5yoh8urCTFX88= github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/olekukonko/tablewriter v0.0.2-0.20190409134802-7e037d187b0c h1:1RHs3tNxjXGHeul8z2t6H2N2TlAqpKe5yryJztRx4Jk= github.com/olekukonko/tablewriter v0.0.2-0.20190409134802-7e037d187b0c/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= -github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pborman/uuid v0.0.0-20170112150404-1b00554d8222/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34= github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g= @@ -249,8 +235,8 @@ github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtP github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7 h1:oYW+YCJ1pachXTQmzR3rNLYGGz4g/UgFcjb28p/viDM= github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -291,9 +277,7 @@ github.com/steakknife/hamming v0.0.0-20180906055917-c99c65617cd3/go.mod h1:hpGUW github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -320,10 +304,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191219195013-becbf705a915/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d h1:2+ZP7EfsZV7Vvmx3TIqSlSzATMkTAKqM14YGFPoSKjI= golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 h1:/ZScEX8SfEmUGRHs0gxpqteO5nfNW6axyZbBdw9A12g= golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= @@ -360,7 +342,6 @@ golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -376,9 +357,7 @@ golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5 h1:LfCXLvNmTYH9kEmVgqbnsWfruoXZIrh4YBgqVHtDvw0= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -388,8 +367,8 @@ golang.org/x/sys v0.0.0-20210309040221-94ec62e08169 h1:fpeMGRM6A+XFcw4RPCO8s8hH7 golang.org/x/sys v0.0.0-20210309040221-94ec62e08169/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -399,14 +378,12 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425150028-36563e24a262 h1:qsl9y/CJx34tuA7QCPNp86JNJe4spst6Ff8MjvPUdPg= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200117012304-6edc0a871e69/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -415,14 +392,12 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20201211151036-40ec1c210f7a h1:GnJAhasbD8HiT8DZMvsEx3QLVy/X0icq/MGr0MqRJ2M= google.golang.org/genproto v0.0.0-20201211151036-40ec1c210f7a/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.27.0 h1:rRYRFMVgRv6E0D70Skyfsr28tDXIuuPZyWGMPdMcnXg= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.33.1 h1:DGeFlSan2f+WEtCERJ4J9GJWk15TxUi8QGagfI87Xyc= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= @@ -438,11 +413,9 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= @@ -453,13 +426,12 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD gopkg.in/urfave/cli.v1 v1.20.0 h1:NdAVW6RYxDif9DhDHaAortIu956m2c0v+09AZBPTbE0= gopkg.in/urfave/cli.v1 v1.20.0/go.mod h1:vuBzUtMdQeixQj8LVd+/98pzhxNGQoyuPBlsXHOQNO0= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.3 h1:fvjTMHxHEw/mxHbtzPi3JCcKXQRAnQTBRo6YCJSVHKI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/pb/api/api.pb.go b/pb/api/api.pb.go index 1567ac5..837df6a 100644 --- a/pb/api/api.pb.go +++ b/pb/api/api.pb.go @@ -1,31 +1,40 @@ +// Copyright (c) 2019 IoTeX +// This program is free software: you can redistribute it and/or modify it under the terms of the +// GNU General Public License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +// the GNU General Public License for more details. +// You should have received a copy of the GNU General Public License along with this program. If +// not, see . + +// To compile the proto, run: +// protoc --go_out=plugins=grpc:. *.proto + // Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.26.0 +// protoc v3.20.1 // source: pb/api/api.proto package api import ( - context "context" - fmt "fmt" - proto "github.com/golang/protobuf/proto" - empty "github.com/golang/protobuf/ptypes/empty" - timestamp "github.com/golang/protobuf/ptypes/timestamp" election "github.com/iotexproject/iotex-election/pb/election" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - math "math" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + emptypb "google.golang.org/protobuf/types/known/emptypb" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" ) -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) type HealthCheckResponse_Status int32 @@ -35,1044 +44,1275 @@ const ( HealthCheckResponse_INACTIVE HealthCheckResponse_Status = 2 ) -var HealthCheckResponse_Status_name = map[int32]string{ - 0: "STARTING", - 1: "ACTIVE", - 2: "INACTIVE", -} +// Enum value maps for HealthCheckResponse_Status. +var ( + HealthCheckResponse_Status_name = map[int32]string{ + 0: "STARTING", + 1: "ACTIVE", + 2: "INACTIVE", + } + HealthCheckResponse_Status_value = map[string]int32{ + "STARTING": 0, + "ACTIVE": 1, + "INACTIVE": 2, + } +) -var HealthCheckResponse_Status_value = map[string]int32{ - "STARTING": 0, - "ACTIVE": 1, - "INACTIVE": 2, +func (x HealthCheckResponse_Status) Enum() *HealthCheckResponse_Status { + p := new(HealthCheckResponse_Status) + *p = x + return p } func (x HealthCheckResponse_Status) String() string { - return proto.EnumName(HealthCheckResponse_Status_name, int32(x)) + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } -func (HealthCheckResponse_Status) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_dfac5a8edb556bfe, []int{7, 0} +func (HealthCheckResponse_Status) Descriptor() protoreflect.EnumDescriptor { + return file_pb_api_api_proto_enumTypes[0].Descriptor() } -type ChainMeta struct { - Height string `protobuf:"bytes,1,opt,name=height,proto3" json:"height,omitempty"` - TotalCandidates uint64 `protobuf:"varint,2,opt,name=totalCandidates,proto3" json:"totalCandidates,omitempty"` - TotalVotedStakes string `protobuf:"bytes,3,opt,name=totalVotedStakes,proto3" json:"totalVotedStakes,omitempty"` - TotalVotes string `protobuf:"bytes,4,opt,name=totalVotes,proto3" json:"totalVotes,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ChainMeta) Reset() { *m = ChainMeta{} } -func (m *ChainMeta) String() string { return proto.CompactTextString(m) } -func (*ChainMeta) ProtoMessage() {} -func (*ChainMeta) Descriptor() ([]byte, []int) { - return fileDescriptor_dfac5a8edb556bfe, []int{0} +func (HealthCheckResponse_Status) Type() protoreflect.EnumType { + return &file_pb_api_api_proto_enumTypes[0] } -func (m *ChainMeta) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ChainMeta.Unmarshal(m, b) +func (x HealthCheckResponse_Status) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) } -func (m *ChainMeta) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ChainMeta.Marshal(b, m, deterministic) + +// Deprecated: Use HealthCheckResponse_Status.Descriptor instead. +func (HealthCheckResponse_Status) EnumDescriptor() ([]byte, []int) { + return file_pb_api_api_proto_rawDescGZIP(), []int{7, 0} } -func (m *ChainMeta) XXX_Merge(src proto.Message) { - xxx_messageInfo_ChainMeta.Merge(m, src) + +type ChainMeta struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Height string `protobuf:"bytes,1,opt,name=height,proto3" json:"height,omitempty"` + TotalCandidates uint64 `protobuf:"varint,2,opt,name=totalCandidates,proto3" json:"totalCandidates,omitempty"` + TotalVotedStakes string `protobuf:"bytes,3,opt,name=totalVotedStakes,proto3" json:"totalVotedStakes,omitempty"` + TotalVotes string `protobuf:"bytes,4,opt,name=totalVotes,proto3" json:"totalVotes,omitempty"` +} + +func (x *ChainMeta) Reset() { + *x = ChainMeta{} + if protoimpl.UnsafeEnabled { + mi := &file_pb_api_api_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *ChainMeta) XXX_Size() int { - return xxx_messageInfo_ChainMeta.Size(m) + +func (x *ChainMeta) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *ChainMeta) XXX_DiscardUnknown() { - xxx_messageInfo_ChainMeta.DiscardUnknown(m) + +func (*ChainMeta) ProtoMessage() {} + +func (x *ChainMeta) ProtoReflect() protoreflect.Message { + mi := &file_pb_api_api_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_ChainMeta proto.InternalMessageInfo +// Deprecated: Use ChainMeta.ProtoReflect.Descriptor instead. +func (*ChainMeta) Descriptor() ([]byte, []int) { + return file_pb_api_api_proto_rawDescGZIP(), []int{0} +} -func (m *ChainMeta) GetHeight() string { - if m != nil { - return m.Height +func (x *ChainMeta) GetHeight() string { + if x != nil { + return x.Height } return "" } -func (m *ChainMeta) GetTotalCandidates() uint64 { - if m != nil { - return m.TotalCandidates +func (x *ChainMeta) GetTotalCandidates() uint64 { + if x != nil { + return x.TotalCandidates } return 0 } -func (m *ChainMeta) GetTotalVotedStakes() string { - if m != nil { - return m.TotalVotedStakes +func (x *ChainMeta) GetTotalVotedStakes() string { + if x != nil { + return x.TotalVotedStakes } return "" } -func (m *ChainMeta) GetTotalVotes() string { - if m != nil { - return m.TotalVotes +func (x *ChainMeta) GetTotalVotes() string { + if x != nil { + return x.TotalVotes } return "" } type Bucket struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + // hex string Voter string `protobuf:"bytes,1,opt,name=voter,proto3" json:"voter,omitempty"` Votes string `protobuf:"bytes,2,opt,name=votes,proto3" json:"votes,omitempty"` WeightedVotes string `protobuf:"bytes,3,opt,name=weightedVotes,proto3" json:"weightedVotes,omitempty"` // human readable duration - RemainingDuration string `protobuf:"bytes,4,opt,name=remainingDuration,proto3" json:"remainingDuration,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + RemainingDuration string `protobuf:"bytes,4,opt,name=remainingDuration,proto3" json:"remainingDuration,omitempty"` } -func (m *Bucket) Reset() { *m = Bucket{} } -func (m *Bucket) String() string { return proto.CompactTextString(m) } -func (*Bucket) ProtoMessage() {} -func (*Bucket) Descriptor() ([]byte, []int) { - return fileDescriptor_dfac5a8edb556bfe, []int{1} +func (x *Bucket) Reset() { + *x = Bucket{} + if protoimpl.UnsafeEnabled { + mi := &file_pb_api_api_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Bucket) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Bucket.Unmarshal(m, b) -} -func (m *Bucket) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Bucket.Marshal(b, m, deterministic) -} -func (m *Bucket) XXX_Merge(src proto.Message) { - xxx_messageInfo_Bucket.Merge(m, src) -} -func (m *Bucket) XXX_Size() int { - return xxx_messageInfo_Bucket.Size(m) +func (x *Bucket) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Bucket) XXX_DiscardUnknown() { - xxx_messageInfo_Bucket.DiscardUnknown(m) + +func (*Bucket) ProtoMessage() {} + +func (x *Bucket) ProtoReflect() protoreflect.Message { + mi := &file_pb_api_api_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_Bucket proto.InternalMessageInfo +// Deprecated: Use Bucket.ProtoReflect.Descriptor instead. +func (*Bucket) Descriptor() ([]byte, []int) { + return file_pb_api_api_proto_rawDescGZIP(), []int{1} +} -func (m *Bucket) GetVoter() string { - if m != nil { - return m.Voter +func (x *Bucket) GetVoter() string { + if x != nil { + return x.Voter } return "" } -func (m *Bucket) GetVotes() string { - if m != nil { - return m.Votes +func (x *Bucket) GetVotes() string { + if x != nil { + return x.Votes } return "" } -func (m *Bucket) GetWeightedVotes() string { - if m != nil { - return m.WeightedVotes +func (x *Bucket) GetWeightedVotes() string { + if x != nil { + return x.WeightedVotes } return "" } -func (m *Bucket) GetRemainingDuration() string { - if m != nil { - return m.RemainingDuration +func (x *Bucket) GetRemainingDuration() string { + if x != nil { + return x.RemainingDuration } return "" } type Candidate struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // hex string - Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` - TotalWeightedVotes string `protobuf:"bytes,3,opt,name=totalWeightedVotes,proto3" json:"totalWeightedVotes,omitempty"` - SelfStakingTokens string `protobuf:"bytes,4,opt,name=selfStakingTokens,proto3" json:"selfStakingTokens,omitempty"` - OperatorAddress string `protobuf:"bytes,5,opt,name=operatorAddress,proto3" json:"operatorAddress,omitempty"` - RewardAddress string `protobuf:"bytes,6,opt,name=rewardAddress,proto3" json:"rewardAddress,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Candidate) Reset() { *m = Candidate{} } -func (m *Candidate) String() string { return proto.CompactTextString(m) } -func (*Candidate) ProtoMessage() {} -func (*Candidate) Descriptor() ([]byte, []int) { - return fileDescriptor_dfac5a8edb556bfe, []int{2} + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + TotalWeightedVotes string `protobuf:"bytes,3,opt,name=totalWeightedVotes,proto3" json:"totalWeightedVotes,omitempty"` + SelfStakingTokens string `protobuf:"bytes,4,opt,name=selfStakingTokens,proto3" json:"selfStakingTokens,omitempty"` + OperatorAddress string `protobuf:"bytes,5,opt,name=operatorAddress,proto3" json:"operatorAddress,omitempty"` + RewardAddress string `protobuf:"bytes,6,opt,name=rewardAddress,proto3" json:"rewardAddress,omitempty"` } -func (m *Candidate) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Candidate.Unmarshal(m, b) -} -func (m *Candidate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Candidate.Marshal(b, m, deterministic) -} -func (m *Candidate) XXX_Merge(src proto.Message) { - xxx_messageInfo_Candidate.Merge(m, src) +func (x *Candidate) Reset() { + *x = Candidate{} + if protoimpl.UnsafeEnabled { + mi := &file_pb_api_api_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Candidate) XXX_Size() int { - return xxx_messageInfo_Candidate.Size(m) + +func (x *Candidate) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Candidate) XXX_DiscardUnknown() { - xxx_messageInfo_Candidate.DiscardUnknown(m) + +func (*Candidate) ProtoMessage() {} + +func (x *Candidate) ProtoReflect() protoreflect.Message { + mi := &file_pb_api_api_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_Candidate proto.InternalMessageInfo +// Deprecated: Use Candidate.ProtoReflect.Descriptor instead. +func (*Candidate) Descriptor() ([]byte, []int) { + return file_pb_api_api_proto_rawDescGZIP(), []int{2} +} -func (m *Candidate) GetName() string { - if m != nil { - return m.Name +func (x *Candidate) GetName() string { + if x != nil { + return x.Name } return "" } -func (m *Candidate) GetAddress() string { - if m != nil { - return m.Address +func (x *Candidate) GetAddress() string { + if x != nil { + return x.Address } return "" } -func (m *Candidate) GetTotalWeightedVotes() string { - if m != nil { - return m.TotalWeightedVotes +func (x *Candidate) GetTotalWeightedVotes() string { + if x != nil { + return x.TotalWeightedVotes } return "" } -func (m *Candidate) GetSelfStakingTokens() string { - if m != nil { - return m.SelfStakingTokens +func (x *Candidate) GetSelfStakingTokens() string { + if x != nil { + return x.SelfStakingTokens } return "" } -func (m *Candidate) GetOperatorAddress() string { - if m != nil { - return m.OperatorAddress +func (x *Candidate) GetOperatorAddress() string { + if x != nil { + return x.OperatorAddress } return "" } -func (m *Candidate) GetRewardAddress() string { - if m != nil { - return m.RewardAddress +func (x *Candidate) GetRewardAddress() string { + if x != nil { + return x.RewardAddress } return "" } type GetCandidatesRequest struct { - Height string `protobuf:"bytes,1,opt,name=height,proto3" json:"height,omitempty"` - Offset uint32 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"` - Limit uint32 `protobuf:"varint,3,opt,name=limit,proto3" json:"limit,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *GetCandidatesRequest) Reset() { *m = GetCandidatesRequest{} } -func (m *GetCandidatesRequest) String() string { return proto.CompactTextString(m) } -func (*GetCandidatesRequest) ProtoMessage() {} -func (*GetCandidatesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dfac5a8edb556bfe, []int{3} + Height string `protobuf:"bytes,1,opt,name=height,proto3" json:"height,omitempty"` + Offset uint32 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"` + Limit uint32 `protobuf:"varint,3,opt,name=limit,proto3" json:"limit,omitempty"` } -func (m *GetCandidatesRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetCandidatesRequest.Unmarshal(m, b) -} -func (m *GetCandidatesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetCandidatesRequest.Marshal(b, m, deterministic) -} -func (m *GetCandidatesRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetCandidatesRequest.Merge(m, src) +func (x *GetCandidatesRequest) Reset() { + *x = GetCandidatesRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_pb_api_api_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *GetCandidatesRequest) XXX_Size() int { - return xxx_messageInfo_GetCandidatesRequest.Size(m) + +func (x *GetCandidatesRequest) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *GetCandidatesRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetCandidatesRequest.DiscardUnknown(m) + +func (*GetCandidatesRequest) ProtoMessage() {} + +func (x *GetCandidatesRequest) ProtoReflect() protoreflect.Message { + mi := &file_pb_api_api_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_GetCandidatesRequest proto.InternalMessageInfo +// Deprecated: Use GetCandidatesRequest.ProtoReflect.Descriptor instead. +func (*GetCandidatesRequest) Descriptor() ([]byte, []int) { + return file_pb_api_api_proto_rawDescGZIP(), []int{3} +} -func (m *GetCandidatesRequest) GetHeight() string { - if m != nil { - return m.Height +func (x *GetCandidatesRequest) GetHeight() string { + if x != nil { + return x.Height } return "" } -func (m *GetCandidatesRequest) GetOffset() uint32 { - if m != nil { - return m.Offset +func (x *GetCandidatesRequest) GetOffset() uint32 { + if x != nil { + return x.Offset } return 0 } -func (m *GetCandidatesRequest) GetLimit() uint32 { - if m != nil { - return m.Limit +func (x *GetCandidatesRequest) GetLimit() uint32 { + if x != nil { + return x.Limit } return 0 } type GetCandidateByNameRequest struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Height string `protobuf:"bytes,2,opt,name=height,proto3" json:"height,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *GetCandidateByNameRequest) Reset() { *m = GetCandidateByNameRequest{} } -func (m *GetCandidateByNameRequest) String() string { return proto.CompactTextString(m) } -func (*GetCandidateByNameRequest) ProtoMessage() {} -func (*GetCandidateByNameRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dfac5a8edb556bfe, []int{4} + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Height string `protobuf:"bytes,2,opt,name=height,proto3" json:"height,omitempty"` } -func (m *GetCandidateByNameRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetCandidateByNameRequest.Unmarshal(m, b) -} -func (m *GetCandidateByNameRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetCandidateByNameRequest.Marshal(b, m, deterministic) -} -func (m *GetCandidateByNameRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetCandidateByNameRequest.Merge(m, src) +func (x *GetCandidateByNameRequest) Reset() { + *x = GetCandidateByNameRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_pb_api_api_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *GetCandidateByNameRequest) XXX_Size() int { - return xxx_messageInfo_GetCandidateByNameRequest.Size(m) + +func (x *GetCandidateByNameRequest) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *GetCandidateByNameRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetCandidateByNameRequest.DiscardUnknown(m) + +func (*GetCandidateByNameRequest) ProtoMessage() {} + +func (x *GetCandidateByNameRequest) ProtoReflect() protoreflect.Message { + mi := &file_pb_api_api_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_GetCandidateByNameRequest proto.InternalMessageInfo +// Deprecated: Use GetCandidateByNameRequest.ProtoReflect.Descriptor instead. +func (*GetCandidateByNameRequest) Descriptor() ([]byte, []int) { + return file_pb_api_api_proto_rawDescGZIP(), []int{4} +} -func (m *GetCandidateByNameRequest) GetName() string { - if m != nil { - return m.Name +func (x *GetCandidateByNameRequest) GetName() string { + if x != nil { + return x.Name } return "" } -func (m *GetCandidateByNameRequest) GetHeight() string { - if m != nil { - return m.Height +func (x *GetCandidateByNameRequest) GetHeight() string { + if x != nil { + return x.Height } return "" } type GetBucketsByCandidateRequest struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Height string `protobuf:"bytes,2,opt,name=height,proto3" json:"height,omitempty"` - Offset uint32 `protobuf:"varint,3,opt,name=offset,proto3" json:"offset,omitempty"` - Limit uint32 `protobuf:"varint,4,opt,name=limit,proto3" json:"limit,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetBucketsByCandidateRequest) Reset() { *m = GetBucketsByCandidateRequest{} } -func (m *GetBucketsByCandidateRequest) String() string { return proto.CompactTextString(m) } -func (*GetBucketsByCandidateRequest) ProtoMessage() {} -func (*GetBucketsByCandidateRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dfac5a8edb556bfe, []int{5} -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *GetBucketsByCandidateRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetBucketsByCandidateRequest.Unmarshal(m, b) -} -func (m *GetBucketsByCandidateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetBucketsByCandidateRequest.Marshal(b, m, deterministic) + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Height string `protobuf:"bytes,2,opt,name=height,proto3" json:"height,omitempty"` + Offset uint32 `protobuf:"varint,3,opt,name=offset,proto3" json:"offset,omitempty"` + Limit uint32 `protobuf:"varint,4,opt,name=limit,proto3" json:"limit,omitempty"` } -func (m *GetBucketsByCandidateRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetBucketsByCandidateRequest.Merge(m, src) + +func (x *GetBucketsByCandidateRequest) Reset() { + *x = GetBucketsByCandidateRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_pb_api_api_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *GetBucketsByCandidateRequest) XXX_Size() int { - return xxx_messageInfo_GetBucketsByCandidateRequest.Size(m) + +func (x *GetBucketsByCandidateRequest) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *GetBucketsByCandidateRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetBucketsByCandidateRequest.DiscardUnknown(m) + +func (*GetBucketsByCandidateRequest) ProtoMessage() {} + +func (x *GetBucketsByCandidateRequest) ProtoReflect() protoreflect.Message { + mi := &file_pb_api_api_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_GetBucketsByCandidateRequest proto.InternalMessageInfo +// Deprecated: Use GetBucketsByCandidateRequest.ProtoReflect.Descriptor instead. +func (*GetBucketsByCandidateRequest) Descriptor() ([]byte, []int) { + return file_pb_api_api_proto_rawDescGZIP(), []int{5} +} -func (m *GetBucketsByCandidateRequest) GetName() string { - if m != nil { - return m.Name +func (x *GetBucketsByCandidateRequest) GetName() string { + if x != nil { + return x.Name } return "" } -func (m *GetBucketsByCandidateRequest) GetHeight() string { - if m != nil { - return m.Height +func (x *GetBucketsByCandidateRequest) GetHeight() string { + if x != nil { + return x.Height } return "" } -func (m *GetBucketsByCandidateRequest) GetOffset() uint32 { - if m != nil { - return m.Offset +func (x *GetBucketsByCandidateRequest) GetOffset() uint32 { + if x != nil { + return x.Offset } return 0 } -func (m *GetBucketsByCandidateRequest) GetLimit() uint32 { - if m != nil { - return m.Limit +func (x *GetBucketsByCandidateRequest) GetLimit() uint32 { + if x != nil { + return x.Limit } return 0 } type GetBucketsRequest struct { - Height string `protobuf:"bytes,1,opt,name=height,proto3" json:"height,omitempty"` - Offset uint32 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"` - Limit uint32 `protobuf:"varint,3,opt,name=limit,proto3" json:"limit,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *GetBucketsRequest) Reset() { *m = GetBucketsRequest{} } -func (m *GetBucketsRequest) String() string { return proto.CompactTextString(m) } -func (*GetBucketsRequest) ProtoMessage() {} -func (*GetBucketsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dfac5a8edb556bfe, []int{6} + Height string `protobuf:"bytes,1,opt,name=height,proto3" json:"height,omitempty"` + Offset uint32 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"` + Limit uint32 `protobuf:"varint,3,opt,name=limit,proto3" json:"limit,omitempty"` } -func (m *GetBucketsRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetBucketsRequest.Unmarshal(m, b) -} -func (m *GetBucketsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetBucketsRequest.Marshal(b, m, deterministic) -} -func (m *GetBucketsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetBucketsRequest.Merge(m, src) +func (x *GetBucketsRequest) Reset() { + *x = GetBucketsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_pb_api_api_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *GetBucketsRequest) XXX_Size() int { - return xxx_messageInfo_GetBucketsRequest.Size(m) + +func (x *GetBucketsRequest) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *GetBucketsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetBucketsRequest.DiscardUnknown(m) + +func (*GetBucketsRequest) ProtoMessage() {} + +func (x *GetBucketsRequest) ProtoReflect() protoreflect.Message { + mi := &file_pb_api_api_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_GetBucketsRequest proto.InternalMessageInfo +// Deprecated: Use GetBucketsRequest.ProtoReflect.Descriptor instead. +func (*GetBucketsRequest) Descriptor() ([]byte, []int) { + return file_pb_api_api_proto_rawDescGZIP(), []int{6} +} -func (m *GetBucketsRequest) GetHeight() string { - if m != nil { - return m.Height +func (x *GetBucketsRequest) GetHeight() string { + if x != nil { + return x.Height } return "" } -func (m *GetBucketsRequest) GetOffset() uint32 { - if m != nil { - return m.Offset +func (x *GetBucketsRequest) GetOffset() uint32 { + if x != nil { + return x.Offset } return 0 } -func (m *GetBucketsRequest) GetLimit() uint32 { - if m != nil { - return m.Limit +func (x *GetBucketsRequest) GetLimit() uint32 { + if x != nil { + return x.Limit } return 0 } type HealthCheckResponse struct { - Status HealthCheckResponse_Status `protobuf:"varint,1,opt,name=status,proto3,enum=api.HealthCheckResponse_Status" json:"status,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *HealthCheckResponse) Reset() { *m = HealthCheckResponse{} } -func (m *HealthCheckResponse) String() string { return proto.CompactTextString(m) } -func (*HealthCheckResponse) ProtoMessage() {} -func (*HealthCheckResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dfac5a8edb556bfe, []int{7} + Status HealthCheckResponse_Status `protobuf:"varint,1,opt,name=status,proto3,enum=api.HealthCheckResponse_Status" json:"status,omitempty"` } -func (m *HealthCheckResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_HealthCheckResponse.Unmarshal(m, b) -} -func (m *HealthCheckResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_HealthCheckResponse.Marshal(b, m, deterministic) -} -func (m *HealthCheckResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_HealthCheckResponse.Merge(m, src) +func (x *HealthCheckResponse) Reset() { + *x = HealthCheckResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_pb_api_api_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *HealthCheckResponse) XXX_Size() int { - return xxx_messageInfo_HealthCheckResponse.Size(m) + +func (x *HealthCheckResponse) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *HealthCheckResponse) XXX_DiscardUnknown() { - xxx_messageInfo_HealthCheckResponse.DiscardUnknown(m) + +func (*HealthCheckResponse) ProtoMessage() {} + +func (x *HealthCheckResponse) ProtoReflect() protoreflect.Message { + mi := &file_pb_api_api_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_HealthCheckResponse proto.InternalMessageInfo +// Deprecated: Use HealthCheckResponse.ProtoReflect.Descriptor instead. +func (*HealthCheckResponse) Descriptor() ([]byte, []int) { + return file_pb_api_api_proto_rawDescGZIP(), []int{7} +} -func (m *HealthCheckResponse) GetStatus() HealthCheckResponse_Status { - if m != nil { - return m.Status +func (x *HealthCheckResponse) GetStatus() HealthCheckResponse_Status { + if x != nil { + return x.Status } return HealthCheckResponse_STARTING } type CandidateResponse struct { - Candidates []*Candidate `protobuf:"bytes,1,rep,name=candidates,proto3" json:"candidates,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *CandidateResponse) Reset() { *m = CandidateResponse{} } -func (m *CandidateResponse) String() string { return proto.CompactTextString(m) } -func (*CandidateResponse) ProtoMessage() {} -func (*CandidateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dfac5a8edb556bfe, []int{8} + Candidates []*Candidate `protobuf:"bytes,1,rep,name=candidates,proto3" json:"candidates,omitempty"` } -func (m *CandidateResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CandidateResponse.Unmarshal(m, b) -} -func (m *CandidateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CandidateResponse.Marshal(b, m, deterministic) -} -func (m *CandidateResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_CandidateResponse.Merge(m, src) +func (x *CandidateResponse) Reset() { + *x = CandidateResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_pb_api_api_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *CandidateResponse) XXX_Size() int { - return xxx_messageInfo_CandidateResponse.Size(m) + +func (x *CandidateResponse) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *CandidateResponse) XXX_DiscardUnknown() { - xxx_messageInfo_CandidateResponse.DiscardUnknown(m) + +func (*CandidateResponse) ProtoMessage() {} + +func (x *CandidateResponse) ProtoReflect() protoreflect.Message { + mi := &file_pb_api_api_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_CandidateResponse proto.InternalMessageInfo +// Deprecated: Use CandidateResponse.ProtoReflect.Descriptor instead. +func (*CandidateResponse) Descriptor() ([]byte, []int) { + return file_pb_api_api_proto_rawDescGZIP(), []int{8} +} -func (m *CandidateResponse) GetCandidates() []*Candidate { - if m != nil { - return m.Candidates +func (x *CandidateResponse) GetCandidates() []*Candidate { + if x != nil { + return x.Candidates } return nil } type BucketResponse struct { - Buckets []*Bucket `protobuf:"bytes,1,rep,name=buckets,proto3" json:"buckets,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *BucketResponse) Reset() { *m = BucketResponse{} } -func (m *BucketResponse) String() string { return proto.CompactTextString(m) } -func (*BucketResponse) ProtoMessage() {} -func (*BucketResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dfac5a8edb556bfe, []int{9} + Buckets []*Bucket `protobuf:"bytes,1,rep,name=buckets,proto3" json:"buckets,omitempty"` } -func (m *BucketResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_BucketResponse.Unmarshal(m, b) -} -func (m *BucketResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_BucketResponse.Marshal(b, m, deterministic) -} -func (m *BucketResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_BucketResponse.Merge(m, src) +func (x *BucketResponse) Reset() { + *x = BucketResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_pb_api_api_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *BucketResponse) XXX_Size() int { - return xxx_messageInfo_BucketResponse.Size(m) + +func (x *BucketResponse) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *BucketResponse) XXX_DiscardUnknown() { - xxx_messageInfo_BucketResponse.DiscardUnknown(m) + +func (*BucketResponse) ProtoMessage() {} + +func (x *BucketResponse) ProtoReflect() protoreflect.Message { + mi := &file_pb_api_api_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_BucketResponse proto.InternalMessageInfo +// Deprecated: Use BucketResponse.ProtoReflect.Descriptor instead. +func (*BucketResponse) Descriptor() ([]byte, []int) { + return file_pb_api_api_proto_rawDescGZIP(), []int{9} +} -func (m *BucketResponse) GetBuckets() []*Bucket { - if m != nil { - return m.Buckets +func (x *BucketResponse) GetBuckets() []*Bucket { + if x != nil { + return x.Buckets } return nil } type GetRawDataRequest struct { - Height string `protobuf:"bytes,1,opt,name=height,proto3" json:"height,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *GetRawDataRequest) Reset() { *m = GetRawDataRequest{} } -func (m *GetRawDataRequest) String() string { return proto.CompactTextString(m) } -func (*GetRawDataRequest) ProtoMessage() {} -func (*GetRawDataRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dfac5a8edb556bfe, []int{10} + Height string `protobuf:"bytes,1,opt,name=height,proto3" json:"height,omitempty"` } -func (m *GetRawDataRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetRawDataRequest.Unmarshal(m, b) -} -func (m *GetRawDataRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetRawDataRequest.Marshal(b, m, deterministic) -} -func (m *GetRawDataRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetRawDataRequest.Merge(m, src) +func (x *GetRawDataRequest) Reset() { + *x = GetRawDataRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_pb_api_api_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *GetRawDataRequest) XXX_Size() int { - return xxx_messageInfo_GetRawDataRequest.Size(m) + +func (x *GetRawDataRequest) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *GetRawDataRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetRawDataRequest.DiscardUnknown(m) + +func (*GetRawDataRequest) ProtoMessage() {} + +func (x *GetRawDataRequest) ProtoReflect() protoreflect.Message { + mi := &file_pb_api_api_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_GetRawDataRequest proto.InternalMessageInfo +// Deprecated: Use GetRawDataRequest.ProtoReflect.Descriptor instead. +func (*GetRawDataRequest) Descriptor() ([]byte, []int) { + return file_pb_api_api_proto_rawDescGZIP(), []int{10} +} -func (m *GetRawDataRequest) GetHeight() string { - if m != nil { - return m.Height +func (x *GetRawDataRequest) GetHeight() string { + if x != nil { + return x.Height } return "" } type RawDataResponse struct { - Timestamp *timestamp.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - Buckets []*election.Bucket `protobuf:"bytes,2,rep,name=buckets,proto3" json:"buckets,omitempty"` - Registrations []*election.Registration `protobuf:"bytes,3,rep,name=registrations,proto3" json:"registrations,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *RawDataResponse) Reset() { *m = RawDataResponse{} } -func (m *RawDataResponse) String() string { return proto.CompactTextString(m) } -func (*RawDataResponse) ProtoMessage() {} -func (*RawDataResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dfac5a8edb556bfe, []int{11} + Timestamp *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + Buckets []*election.Bucket `protobuf:"bytes,2,rep,name=buckets,proto3" json:"buckets,omitempty"` + Registrations []*election.Registration `protobuf:"bytes,3,rep,name=registrations,proto3" json:"registrations,omitempty"` } -func (m *RawDataResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_RawDataResponse.Unmarshal(m, b) -} -func (m *RawDataResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_RawDataResponse.Marshal(b, m, deterministic) -} -func (m *RawDataResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_RawDataResponse.Merge(m, src) -} -func (m *RawDataResponse) XXX_Size() int { - return xxx_messageInfo_RawDataResponse.Size(m) +func (x *RawDataResponse) Reset() { + *x = RawDataResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_pb_api_api_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *RawDataResponse) XXX_DiscardUnknown() { - xxx_messageInfo_RawDataResponse.DiscardUnknown(m) + +func (x *RawDataResponse) String() string { + return protoimpl.X.MessageStringOf(x) } -var xxx_messageInfo_RawDataResponse proto.InternalMessageInfo +func (*RawDataResponse) ProtoMessage() {} -func (m *RawDataResponse) GetTimestamp() *timestamp.Timestamp { - if m != nil { - return m.Timestamp +func (x *RawDataResponse) ProtoReflect() protoreflect.Message { + mi := &file_pb_api_api_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return nil + return mi.MessageOf(x) } -func (m *RawDataResponse) GetBuckets() []*election.Bucket { - if m != nil { - return m.Buckets - } - return nil +// Deprecated: Use RawDataResponse.ProtoReflect.Descriptor instead. +func (*RawDataResponse) Descriptor() ([]byte, []int) { + return file_pb_api_api_proto_rawDescGZIP(), []int{11} } -func (m *RawDataResponse) GetRegistrations() []*election.Registration { - if m != nil { - return m.Registrations +func (x *RawDataResponse) GetTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.Timestamp } return nil } -func init() { - proto.RegisterEnum("api.HealthCheckResponse_Status", HealthCheckResponse_Status_name, HealthCheckResponse_Status_value) - proto.RegisterType((*ChainMeta)(nil), "api.ChainMeta") - proto.RegisterType((*Bucket)(nil), "api.Bucket") - proto.RegisterType((*Candidate)(nil), "api.Candidate") - proto.RegisterType((*GetCandidatesRequest)(nil), "api.GetCandidatesRequest") - proto.RegisterType((*GetCandidateByNameRequest)(nil), "api.GetCandidateByNameRequest") - proto.RegisterType((*GetBucketsByCandidateRequest)(nil), "api.GetBucketsByCandidateRequest") - proto.RegisterType((*GetBucketsRequest)(nil), "api.GetBucketsRequest") - proto.RegisterType((*HealthCheckResponse)(nil), "api.HealthCheckResponse") - proto.RegisterType((*CandidateResponse)(nil), "api.CandidateResponse") - proto.RegisterType((*BucketResponse)(nil), "api.BucketResponse") - proto.RegisterType((*GetRawDataRequest)(nil), "api.GetRawDataRequest") - proto.RegisterType((*RawDataResponse)(nil), "api.RawDataResponse") -} - -func init() { proto.RegisterFile("pb/api/api.proto", fileDescriptor_dfac5a8edb556bfe) } - -var fileDescriptor_dfac5a8edb556bfe = []byte{ - // 813 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x5f, 0x6f, 0x1b, 0x45, - 0x10, 0xf7, 0xc5, 0xe9, 0xa5, 0x99, 0x90, 0xd4, 0xd9, 0x06, 0xcb, 0x3d, 0x50, 0x1b, 0x56, 0x20, - 0x45, 0x85, 0x9e, 0x51, 0xfa, 0x50, 0x24, 0x2a, 0xa4, 0xc4, 0x29, 0xc1, 0x0f, 0x44, 0x70, 0xb6, - 0x8a, 0x40, 0xbc, 0xac, 0xed, 0xf1, 0x79, 0xb1, 0xef, 0xf6, 0xb8, 0x5d, 0x37, 0xcd, 0x1b, 0x8f, - 0x7c, 0x05, 0x3e, 0x08, 0x1f, 0x87, 0x67, 0xbe, 0x06, 0xba, 0xdd, 0xbd, 0x3f, 0x3e, 0xdb, 0xaa, - 0x84, 0xfa, 0x60, 0xc9, 0x33, 0xf3, 0xdb, 0x99, 0xdf, 0xfc, 0x76, 0x67, 0x0e, 0x5a, 0xc9, 0xa8, - 0xcb, 0x12, 0x9e, 0xfd, 0xfc, 0x24, 0x15, 0x4a, 0x90, 0x26, 0x4b, 0xb8, 0xf7, 0x51, 0x28, 0x44, - 0xb8, 0xc0, 0xae, 0x76, 0x8d, 0x96, 0xd3, 0x2e, 0x46, 0x89, 0xba, 0x33, 0x08, 0xef, 0x49, 0x3d, - 0xa8, 0x78, 0x84, 0x52, 0xb1, 0x28, 0xb1, 0x00, 0x2f, 0x19, 0x75, 0x71, 0x81, 0x63, 0xc5, 0x45, - 0x5c, 0xfc, 0x31, 0x31, 0xfa, 0x97, 0x03, 0xfb, 0xbd, 0x19, 0xe3, 0xf1, 0xf7, 0xa8, 0x18, 0x69, - 0x83, 0x3b, 0x43, 0x1e, 0xce, 0x54, 0xc7, 0x39, 0x75, 0xce, 0xf6, 0x03, 0x6b, 0x91, 0x33, 0x78, - 0xa0, 0x84, 0x62, 0x8b, 0x1e, 0x8b, 0x27, 0x7c, 0xc2, 0x14, 0xca, 0xce, 0xce, 0xa9, 0x73, 0xb6, - 0x1b, 0xd4, 0xdd, 0xe4, 0x29, 0xb4, 0xb4, 0xeb, 0xb5, 0x50, 0x38, 0x19, 0x28, 0x36, 0x47, 0xd9, - 0x69, 0xea, 0x5c, 0x6b, 0x7e, 0xf2, 0x18, 0xa0, 0xf0, 0xc9, 0xce, 0xae, 0x46, 0x55, 0x3c, 0xf4, - 0x4f, 0x07, 0xdc, 0xcb, 0xe5, 0x78, 0x8e, 0x8a, 0x9c, 0xc0, 0xbd, 0x37, 0x42, 0x61, 0x6a, 0x79, - 0x19, 0x23, 0xf7, 0x1a, 0x32, 0xd6, 0x2b, 0xc9, 0xa7, 0x70, 0x78, 0xab, 0x69, 0xe3, 0xc4, 0x64, - 0x36, 0xf5, 0x57, 0x9d, 0xe4, 0x0b, 0x38, 0x4e, 0x31, 0x62, 0x3c, 0xe6, 0x71, 0x78, 0xb5, 0x4c, - 0x59, 0xa6, 0x89, 0xe5, 0xb0, 0x1e, 0xa0, 0xff, 0x66, 0x32, 0xe5, 0x5d, 0x12, 0x02, 0xbb, 0x31, - 0x8b, 0xd0, 0x92, 0xd1, 0xff, 0x49, 0x07, 0xf6, 0xd8, 0x64, 0x92, 0xa2, 0xcc, 0xd9, 0xe4, 0x26, - 0xf1, 0x81, 0xe8, 0xa6, 0x7e, 0xda, 0x40, 0x6a, 0x43, 0x24, 0x63, 0x26, 0x71, 0x31, 0xcd, 0x44, - 0xe2, 0x71, 0x38, 0x14, 0x73, 0x8c, 0x73, 0x75, 0xd6, 0x03, 0xd9, 0xd5, 0x88, 0x04, 0x53, 0xa6, - 0x44, 0x7a, 0x61, 0xeb, 0xdf, 0xd3, 0xd8, 0xba, 0x3b, 0xd3, 0x25, 0xc5, 0x5b, 0x96, 0x4e, 0x72, - 0x9c, 0x6b, 0x74, 0x59, 0x71, 0xd2, 0x5f, 0xe1, 0xe4, 0x1a, 0x55, 0x79, 0xa3, 0x01, 0xfe, 0xbe, - 0x44, 0xa9, 0xb6, 0x3e, 0x8d, 0x36, 0xb8, 0x62, 0x3a, 0x95, 0xa8, 0x74, 0xdb, 0x87, 0x81, 0xb5, - 0xb2, 0xbb, 0x59, 0xf0, 0x88, 0x2b, 0xdd, 0xe8, 0x61, 0x60, 0x0c, 0x7a, 0x0d, 0x8f, 0xaa, 0xd9, - 0x2f, 0xef, 0x6e, 0x58, 0x84, 0x79, 0x89, 0x4d, 0xb2, 0x96, 0x65, 0x77, 0xaa, 0x65, 0xe9, 0x5b, - 0xf8, 0xf8, 0x1a, 0x95, 0x79, 0x1d, 0xf2, 0xf2, 0xae, 0xc8, 0xf8, 0x3f, 0x72, 0x55, 0x5a, 0x68, - 0x6e, 0x6e, 0x61, 0xb7, 0xda, 0xc2, 0xcf, 0x70, 0x5c, 0x56, 0x7e, 0xbf, 0xea, 0xfc, 0xe1, 0xc0, - 0xc3, 0xef, 0x90, 0x2d, 0xd4, 0xac, 0x37, 0xc3, 0xf1, 0x3c, 0x40, 0x99, 0x88, 0x58, 0x22, 0x79, - 0x01, 0xae, 0x54, 0x4c, 0x2d, 0xa5, 0xce, 0x7e, 0x74, 0xfe, 0xc4, 0xcf, 0xf6, 0xc3, 0x06, 0xa4, - 0x3f, 0xd0, 0xb0, 0xc0, 0xc2, 0xe9, 0x97, 0xe0, 0x1a, 0x0f, 0xf9, 0x00, 0xee, 0x0f, 0x86, 0x17, - 0xc1, 0xb0, 0x7f, 0x73, 0xdd, 0x6a, 0x10, 0x00, 0xf7, 0xa2, 0x37, 0xec, 0xbf, 0x7e, 0xd5, 0x72, - 0xb2, 0x48, 0xff, 0xc6, 0x5a, 0x3b, 0xb4, 0x07, 0xc7, 0x15, 0x2d, 0x6d, 0x7d, 0x1f, 0x60, 0x5c, - 0x4e, 0xbe, 0x73, 0xda, 0x3c, 0x3b, 0x38, 0x3f, 0xd2, 0x1c, 0x4a, 0x6c, 0x05, 0x41, 0x5f, 0xc0, - 0x91, 0xd1, 0xa7, 0xc8, 0xf0, 0x19, 0xec, 0x8d, 0x8c, 0x62, 0xf6, 0xf8, 0x81, 0x3e, 0x6e, 0x51, - 0x79, 0x8c, 0x7e, 0xae, 0xb5, 0x0d, 0xd8, 0xed, 0x15, 0x53, 0xec, 0x1d, 0xda, 0xd2, 0xbf, 0x1d, - 0x78, 0x50, 0x40, 0x6d, 0x9d, 0xaf, 0x60, 0xbf, 0xd8, 0x7e, 0x1a, 0x7e, 0x70, 0xee, 0xf9, 0x66, - 0x3f, 0xfa, 0xf9, 0x7e, 0xf4, 0x87, 0x39, 0x22, 0x28, 0xc1, 0xe4, 0x69, 0xc9, 0x70, 0x47, 0x33, - 0x6c, 0xf9, 0xc5, 0xaa, 0xac, 0xd1, 0x24, 0x2f, 0xb3, 0x49, 0x0a, 0xb9, 0x54, 0x66, 0x3b, 0x64, - 0xc3, 0x9c, 0x9d, 0x68, 0x97, 0x27, 0x82, 0x4a, 0x38, 0x58, 0x05, 0x9f, 0xff, 0xd3, 0x04, 0xb8, - 0xf8, 0xa1, 0x3f, 0xc0, 0xf4, 0x0d, 0x1f, 0x23, 0x79, 0x0e, 0x7b, 0x21, 0x2a, 0xb3, 0x7e, 0xd7, - 0xa8, 0xbe, 0xca, 0xf6, 0xbc, 0x67, 0xb5, 0xce, 0xd7, 0x34, 0x6d, 0x90, 0x2b, 0x38, 0x0c, 0xab, - 0x53, 0x4a, 0x1e, 0x69, 0xc8, 0xa6, 0xc9, 0xf5, 0xda, 0xb5, 0x9b, 0xb2, 0x5a, 0xd1, 0x06, 0xf9, - 0x16, 0x48, 0xb8, 0x36, 0x8d, 0xe4, 0xf1, 0x5a, 0xaa, 0x95, 0x31, 0xf5, 0x6a, 0x37, 0x4f, 0x1b, - 0xe4, 0x47, 0xf8, 0x30, 0xdc, 0x34, 0x8c, 0xe4, 0x93, 0x3c, 0xd5, 0xd6, 0x41, 0xf5, 0x1e, 0x56, - 0x1f, 0x42, 0x49, 0xed, 0x6b, 0x80, 0x32, 0x25, 0x69, 0xd7, 0xf2, 0xbc, 0xe3, 0xf0, 0x37, 0x70, - 0x9f, 0x4b, 0x33, 0x1e, 0x5b, 0x35, 0xed, 0x6c, 0x9b, 0x21, 0xda, 0x20, 0x2f, 0x75, 0x71, 0xfb, - 0xb6, 0xca, 0xe2, 0xab, 0xef, 0xd2, 0x3b, 0xd1, 0xfe, 0xda, 0x0b, 0xa4, 0x8d, 0xcb, 0xee, 0x2f, - 0xcf, 0x42, 0xae, 0x66, 0xcb, 0x91, 0x3f, 0x16, 0x51, 0x97, 0x0b, 0x85, 0x6f, 0x93, 0x54, 0xfc, - 0x86, 0x63, 0x65, 0x8c, 0x67, 0xc5, 0xb7, 0xd8, 0x7c, 0xec, 0x47, 0xae, 0xa6, 0xf6, 0xfc, 0xbf, - 0x00, 0x00, 0x00, 0xff, 0xff, 0x0c, 0x4a, 0x50, 0x4c, 0xfd, 0x07, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// APIServiceClient is the client API for APIService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type APIServiceClient interface { - // get the blockchain meta data - GetMeta(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*ChainMeta, error) - // get candidates - GetCandidates(ctx context.Context, in *GetCandidatesRequest, opts ...grpc.CallOption) (*CandidateResponse, error) - // get candidate by name - GetCandidateByName(ctx context.Context, in *GetCandidateByNameRequest, opts ...grpc.CallOption) (*Candidate, error) - // get buckets by candidate - GetBucketsByCandidate(ctx context.Context, in *GetBucketsByCandidateRequest, opts ...grpc.CallOption) (*BucketResponse, error) - // get Buckets - GetBuckets(ctx context.Context, in *GetBucketsRequest, opts ...grpc.CallOption) (*BucketResponse, error) - // health endpoint - IsHealth(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*HealthCheckResponse, error) - //get raw data by height - GetRawData(ctx context.Context, in *GetRawDataRequest, opts ...grpc.CallOption) (*RawDataResponse, error) -} - -type aPIServiceClient struct { - cc *grpc.ClientConn -} - -func NewAPIServiceClient(cc *grpc.ClientConn) APIServiceClient { - return &aPIServiceClient{cc} -} - -func (c *aPIServiceClient) GetMeta(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*ChainMeta, error) { - out := new(ChainMeta) - err := c.cc.Invoke(ctx, "/api.APIService/getMeta", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *aPIServiceClient) GetCandidates(ctx context.Context, in *GetCandidatesRequest, opts ...grpc.CallOption) (*CandidateResponse, error) { - out := new(CandidateResponse) - err := c.cc.Invoke(ctx, "/api.APIService/getCandidates", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *aPIServiceClient) GetCandidateByName(ctx context.Context, in *GetCandidateByNameRequest, opts ...grpc.CallOption) (*Candidate, error) { - out := new(Candidate) - err := c.cc.Invoke(ctx, "/api.APIService/getCandidateByName", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *aPIServiceClient) GetBucketsByCandidate(ctx context.Context, in *GetBucketsByCandidateRequest, opts ...grpc.CallOption) (*BucketResponse, error) { - out := new(BucketResponse) - err := c.cc.Invoke(ctx, "/api.APIService/getBucketsByCandidate", in, out, opts...) - if err != nil { - return nil, err +func (x *RawDataResponse) GetBuckets() []*election.Bucket { + if x != nil { + return x.Buckets } - return out, nil + return nil } -func (c *aPIServiceClient) GetBuckets(ctx context.Context, in *GetBucketsRequest, opts ...grpc.CallOption) (*BucketResponse, error) { - out := new(BucketResponse) - err := c.cc.Invoke(ctx, "/api.APIService/getBuckets", in, out, opts...) - if err != nil { - return nil, err +func (x *RawDataResponse) GetRegistrations() []*election.Registration { + if x != nil { + return x.Registrations } - return out, nil + return nil } -func (c *aPIServiceClient) IsHealth(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*HealthCheckResponse, error) { - out := new(HealthCheckResponse) - err := c.cc.Invoke(ctx, "/api.APIService/isHealth", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil +type ProofRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` } -func (c *aPIServiceClient) GetRawData(ctx context.Context, in *GetRawDataRequest, opts ...grpc.CallOption) (*RawDataResponse, error) { - out := new(RawDataResponse) - err := c.cc.Invoke(ctx, "/api.APIService/getRawData", in, out, opts...) - if err != nil { - return nil, err +func (x *ProofRequest) Reset() { + *x = ProofRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_pb_api_api_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - return out, nil } -// APIServiceServer is the server API for APIService service. -type APIServiceServer interface { - // get the blockchain meta data - GetMeta(context.Context, *empty.Empty) (*ChainMeta, error) - // get candidates - GetCandidates(context.Context, *GetCandidatesRequest) (*CandidateResponse, error) - // get candidate by name - GetCandidateByName(context.Context, *GetCandidateByNameRequest) (*Candidate, error) - // get buckets by candidate - GetBucketsByCandidate(context.Context, *GetBucketsByCandidateRequest) (*BucketResponse, error) - // get Buckets - GetBuckets(context.Context, *GetBucketsRequest) (*BucketResponse, error) - // health endpoint - IsHealth(context.Context, *empty.Empty) (*HealthCheckResponse, error) - //get raw data by height - GetRawData(context.Context, *GetRawDataRequest) (*RawDataResponse, error) +func (x *ProofRequest) String() string { + return protoimpl.X.MessageStringOf(x) } -// UnimplementedAPIServiceServer can be embedded to have forward compatible implementations. -type UnimplementedAPIServiceServer struct { -} +func (*ProofRequest) ProtoMessage() {} -func (*UnimplementedAPIServiceServer) GetMeta(ctx context.Context, req *empty.Empty) (*ChainMeta, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetMeta not implemented") -} -func (*UnimplementedAPIServiceServer) GetCandidates(ctx context.Context, req *GetCandidatesRequest) (*CandidateResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetCandidates not implemented") -} -func (*UnimplementedAPIServiceServer) GetCandidateByName(ctx context.Context, req *GetCandidateByNameRequest) (*Candidate, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetCandidateByName not implemented") -} -func (*UnimplementedAPIServiceServer) GetBucketsByCandidate(ctx context.Context, req *GetBucketsByCandidateRequest) (*BucketResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetBucketsByCandidate not implemented") -} -func (*UnimplementedAPIServiceServer) GetBuckets(ctx context.Context, req *GetBucketsRequest) (*BucketResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetBuckets not implemented") -} -func (*UnimplementedAPIServiceServer) IsHealth(ctx context.Context, req *empty.Empty) (*HealthCheckResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method IsHealth not implemented") -} -func (*UnimplementedAPIServiceServer) GetRawData(ctx context.Context, req *GetRawDataRequest) (*RawDataResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetRawData not implemented") +func (x *ProofRequest) ProtoReflect() protoreflect.Message { + mi := &file_pb_api_api_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -func RegisterAPIServiceServer(s *grpc.Server, srv APIServiceServer) { - s.RegisterService(&_APIService_serviceDesc, srv) +// Deprecated: Use ProofRequest.ProtoReflect.Descriptor instead. +func (*ProofRequest) Descriptor() ([]byte, []int) { + return file_pb_api_api_proto_rawDescGZIP(), []int{12} } -func _APIService_GetMeta_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(empty.Empty) - if err := dec(in); err != nil { - return nil, err +func (x *ProofRequest) GetAccount() string { + if x != nil { + return x.Account } - if interceptor == nil { - return srv.(APIServiceServer).GetMeta(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/api.APIService/GetMeta", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(APIServiceServer).GetMeta(ctx, req.(*empty.Empty)) - } - return interceptor(ctx, in, info, handler) + return "" } -func _APIService_GetCandidates_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetCandidatesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(APIServiceServer).GetCandidates(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/api.APIService/GetCandidates", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(APIServiceServer).GetCandidates(ctx, req.(*GetCandidatesRequest)) - } - return interceptor(ctx, in, info, handler) +type ProofResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Proof string `protobuf:"bytes,1,opt,name=proof,proto3" json:"proof,omitempty"` } -func _APIService_GetCandidateByName_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetCandidateByNameRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(APIServiceServer).GetCandidateByName(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/api.APIService/GetCandidateByName", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(APIServiceServer).GetCandidateByName(ctx, req.(*GetCandidateByNameRequest)) +func (x *ProofResponse) Reset() { + *x = ProofResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_pb_api_api_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - return interceptor(ctx, in, info, handler) } -func _APIService_GetBucketsByCandidate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetBucketsByCandidateRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(APIServiceServer).GetBucketsByCandidate(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/api.APIService/GetBucketsByCandidate", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(APIServiceServer).GetBucketsByCandidate(ctx, req.(*GetBucketsByCandidateRequest)) - } - return interceptor(ctx, in, info, handler) +func (x *ProofResponse) String() string { + return protoimpl.X.MessageStringOf(x) } -func _APIService_GetBuckets_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetBucketsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(APIServiceServer).GetBuckets(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/api.APIService/GetBuckets", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(APIServiceServer).GetBuckets(ctx, req.(*GetBucketsRequest)) +func (*ProofResponse) ProtoMessage() {} + +func (x *ProofResponse) ProtoReflect() protoreflect.Message { + mi := &file_pb_api_api_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return interceptor(ctx, in, info, handler) + return mi.MessageOf(x) } -func _APIService_IsHealth_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(empty.Empty) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(APIServiceServer).IsHealth(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/api.APIService/IsHealth", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(APIServiceServer).IsHealth(ctx, req.(*empty.Empty)) - } - return interceptor(ctx, in, info, handler) +// Deprecated: Use ProofResponse.ProtoReflect.Descriptor instead. +func (*ProofResponse) Descriptor() ([]byte, []int) { + return file_pb_api_api_proto_rawDescGZIP(), []int{13} } -func _APIService_GetRawData_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetRawDataRequest) - if err := dec(in); err != nil { - return nil, err +func (x *ProofResponse) GetProof() string { + if x != nil { + return x.Proof } - if interceptor == nil { - return srv.(APIServiceServer).GetRawData(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/api.APIService/GetRawData", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(APIServiceServer).GetRawData(ctx, req.(*GetRawDataRequest)) - } - return interceptor(ctx, in, info, handler) + return "" } -var _APIService_serviceDesc = grpc.ServiceDesc{ - ServiceName: "api.APIService", - HandlerType: (*APIServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "getMeta", - Handler: _APIService_GetMeta_Handler, - }, - { - MethodName: "getCandidates", - Handler: _APIService_GetCandidates_Handler, - }, - { - MethodName: "getCandidateByName", - Handler: _APIService_GetCandidateByName_Handler, - }, - { - MethodName: "getBucketsByCandidate", - Handler: _APIService_GetBucketsByCandidate_Handler, - }, - { - MethodName: "getBuckets", - Handler: _APIService_GetBuckets_Handler, - }, - { - MethodName: "isHealth", - Handler: _APIService_IsHealth_Handler, - }, - { - MethodName: "getRawData", - Handler: _APIService_GetRawData_Handler, +var File_pb_api_api_proto protoreflect.FileDescriptor + +var file_pb_api_api_proto_rawDesc = []byte{ + 0x0a, 0x10, 0x70, 0x62, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x12, 0x03, 0x61, 0x70, 0x69, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1a, 0x70, 0x62, 0x2f, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x2f, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x22, 0x99, 0x01, 0x0a, 0x09, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x4d, 0x65, 0x74, 0x61, 0x12, + 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x28, 0x0a, 0x0f, 0x74, 0x6f, 0x74, 0x61, 0x6c, + 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, + 0x52, 0x0f, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, + 0x73, 0x12, 0x2a, 0x0a, 0x10, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x56, 0x6f, 0x74, 0x65, 0x64, 0x53, + 0x74, 0x61, 0x6b, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x74, 0x6f, 0x74, + 0x61, 0x6c, 0x56, 0x6f, 0x74, 0x65, 0x64, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x73, 0x12, 0x1e, 0x0a, + 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x56, 0x6f, 0x74, 0x65, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x56, 0x6f, 0x74, 0x65, 0x73, 0x22, 0x88, 0x01, + 0x0a, 0x06, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x6f, 0x74, 0x65, + 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x6f, 0x74, 0x65, 0x72, 0x12, 0x14, + 0x0a, 0x05, 0x76, 0x6f, 0x74, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, + 0x6f, 0x74, 0x65, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x65, 0x64, + 0x56, 0x6f, 0x74, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x77, 0x65, 0x69, + 0x67, 0x68, 0x74, 0x65, 0x64, 0x56, 0x6f, 0x74, 0x65, 0x73, 0x12, 0x2c, 0x0a, 0x11, 0x72, 0x65, + 0x6d, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x72, 0x65, 0x6d, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, + 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xe7, 0x01, 0x0a, 0x09, 0x43, 0x61, 0x6e, + 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, + 0x72, 0x65, 0x73, 0x73, 0x12, 0x2e, 0x0a, 0x12, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x57, 0x65, 0x69, + 0x67, 0x68, 0x74, 0x65, 0x64, 0x56, 0x6f, 0x74, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x12, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x57, 0x65, 0x69, 0x67, 0x68, 0x74, 0x65, 0x64, 0x56, + 0x6f, 0x74, 0x65, 0x73, 0x12, 0x2c, 0x0a, 0x11, 0x73, 0x65, 0x6c, 0x66, 0x53, 0x74, 0x61, 0x6b, + 0x69, 0x6e, 0x67, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x11, 0x73, 0x65, 0x6c, 0x66, 0x53, 0x74, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x54, 0x6f, 0x6b, 0x65, + 0x6e, 0x73, 0x12, 0x28, 0x0a, 0x0f, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x41, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x6f, 0x70, 0x65, + 0x72, 0x61, 0x74, 0x6f, 0x72, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x24, 0x0a, 0x0d, + 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0d, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x22, 0x5c, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, + 0x74, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, + 0x69, 0x67, 0x68, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, + 0x68, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0d, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, + 0x6d, 0x69, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, + 0x22, 0x47, 0x0a, 0x19, 0x47, 0x65, 0x74, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, + 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0x78, 0x0a, 0x1c, 0x47, 0x65, 0x74, + 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x42, 0x79, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, + 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, + 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x68, + 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x14, 0x0a, + 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x6c, 0x69, + 0x6d, 0x69, 0x74, 0x22, 0x59, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, + 0x68, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, + 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, + 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, + 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x80, + 0x01, 0x0a, 0x13, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x37, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x48, 0x65, 0x61, + 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, + 0x30, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0c, 0x0a, 0x08, 0x53, 0x54, 0x41, + 0x52, 0x54, 0x49, 0x4e, 0x47, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x41, 0x43, 0x54, 0x49, 0x56, + 0x45, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x49, 0x4e, 0x41, 0x43, 0x54, 0x49, 0x56, 0x45, 0x10, + 0x02, 0x22, 0x43, 0x0a, 0x11, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2e, 0x0a, 0x0a, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, + 0x61, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x61, 0x70, 0x69, + 0x2e, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x0a, 0x63, 0x61, 0x6e, 0x64, + 0x69, 0x64, 0x61, 0x74, 0x65, 0x73, 0x22, 0x37, 0x0a, 0x0e, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x07, 0x62, 0x75, 0x63, 0x6b, + 0x65, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x61, 0x70, 0x69, 0x2e, + 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x52, 0x07, 0x62, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x22, + 0x2b, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x52, 0x61, 0x77, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0xb5, 0x01, 0x0a, + 0x0f, 0x52, 0x61, 0x77, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, + 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x2a, 0x0a, 0x07, 0x62, 0x75, + 0x63, 0x6b, 0x65, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x65, 0x6c, + 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x52, 0x07, 0x62, + 0x75, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x12, 0x3c, 0x0a, 0x0d, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, + 0x65, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0d, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x28, 0x0a, 0x0c, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x25, + 0x0a, 0x0d, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x14, 0x0a, 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x32, 0x92, 0x04, 0x0a, 0x0a, 0x41, 0x50, 0x49, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x12, 0x33, 0x0a, 0x07, 0x67, 0x65, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x12, + 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x0e, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x68, + 0x61, 0x69, 0x6e, 0x4d, 0x65, 0x74, 0x61, 0x22, 0x00, 0x12, 0x44, 0x0a, 0x0d, 0x67, 0x65, 0x74, + 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x73, 0x12, 0x19, 0x2e, 0x61, 0x70, 0x69, + 0x2e, 0x47, 0x65, 0x74, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x73, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x61, 0x6e, 0x64, + 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x46, 0x0a, 0x12, 0x67, 0x65, 0x74, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x42, + 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1e, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x43, + 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x61, 0x6e, 0x64, + 0x69, 0x64, 0x61, 0x74, 0x65, 0x22, 0x00, 0x12, 0x51, 0x0a, 0x15, 0x67, 0x65, 0x74, 0x42, 0x75, + 0x63, 0x6b, 0x65, 0x74, 0x73, 0x42, 0x79, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, + 0x12, 0x21, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, + 0x73, 0x42, 0x79, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x0a, 0x67, 0x65, + 0x74, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x12, 0x16, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, + 0x65, 0x74, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x13, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x08, 0x69, 0x73, 0x48, 0x65, 0x61, + 0x6c, 0x74, 0x68, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x18, 0x2e, 0x61, 0x70, + 0x69, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3c, 0x0a, 0x0a, 0x67, 0x65, 0x74, 0x52, 0x61, + 0x77, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x52, + 0x61, 0x77, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, + 0x61, 0x70, 0x69, 0x2e, 0x52, 0x61, 0x77, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x33, 0x0a, 0x08, 0x67, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6f, + 0x66, 0x12, 0x11, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x72, 0x6f, 0x6f, 0x66, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x2f, 0x5a, 0x2d, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x6f, 0x74, 0x65, 0x78, 0x70, 0x72, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x69, 0x6f, 0x74, 0x65, 0x78, 0x2d, 0x65, 0x6c, 0x65, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x70, 0x62, 0x2f, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, +} + +var ( + file_pb_api_api_proto_rawDescOnce sync.Once + file_pb_api_api_proto_rawDescData = file_pb_api_api_proto_rawDesc +) + +func file_pb_api_api_proto_rawDescGZIP() []byte { + file_pb_api_api_proto_rawDescOnce.Do(func() { + file_pb_api_api_proto_rawDescData = protoimpl.X.CompressGZIP(file_pb_api_api_proto_rawDescData) + }) + return file_pb_api_api_proto_rawDescData +} + +var file_pb_api_api_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_pb_api_api_proto_msgTypes = make([]protoimpl.MessageInfo, 14) +var file_pb_api_api_proto_goTypes = []interface{}{ + (HealthCheckResponse_Status)(0), // 0: api.HealthCheckResponse.Status + (*ChainMeta)(nil), // 1: api.ChainMeta + (*Bucket)(nil), // 2: api.Bucket + (*Candidate)(nil), // 3: api.Candidate + (*GetCandidatesRequest)(nil), // 4: api.GetCandidatesRequest + (*GetCandidateByNameRequest)(nil), // 5: api.GetCandidateByNameRequest + (*GetBucketsByCandidateRequest)(nil), // 6: api.GetBucketsByCandidateRequest + (*GetBucketsRequest)(nil), // 7: api.GetBucketsRequest + (*HealthCheckResponse)(nil), // 8: api.HealthCheckResponse + (*CandidateResponse)(nil), // 9: api.CandidateResponse + (*BucketResponse)(nil), // 10: api.BucketResponse + (*GetRawDataRequest)(nil), // 11: api.GetRawDataRequest + (*RawDataResponse)(nil), // 12: api.RawDataResponse + (*ProofRequest)(nil), // 13: api.ProofRequest + (*ProofResponse)(nil), // 14: api.ProofResponse + (*timestamppb.Timestamp)(nil), // 15: google.protobuf.Timestamp + (*election.Bucket)(nil), // 16: election.Bucket + (*election.Registration)(nil), // 17: election.Registration + (*emptypb.Empty)(nil), // 18: google.protobuf.Empty +} +var file_pb_api_api_proto_depIdxs = []int32{ + 0, // 0: api.HealthCheckResponse.status:type_name -> api.HealthCheckResponse.Status + 3, // 1: api.CandidateResponse.candidates:type_name -> api.Candidate + 2, // 2: api.BucketResponse.buckets:type_name -> api.Bucket + 15, // 3: api.RawDataResponse.timestamp:type_name -> google.protobuf.Timestamp + 16, // 4: api.RawDataResponse.buckets:type_name -> election.Bucket + 17, // 5: api.RawDataResponse.registrations:type_name -> election.Registration + 18, // 6: api.APIService.getMeta:input_type -> google.protobuf.Empty + 4, // 7: api.APIService.getCandidates:input_type -> api.GetCandidatesRequest + 5, // 8: api.APIService.getCandidateByName:input_type -> api.GetCandidateByNameRequest + 6, // 9: api.APIService.getBucketsByCandidate:input_type -> api.GetBucketsByCandidateRequest + 7, // 10: api.APIService.getBuckets:input_type -> api.GetBucketsRequest + 18, // 11: api.APIService.isHealth:input_type -> google.protobuf.Empty + 11, // 12: api.APIService.getRawData:input_type -> api.GetRawDataRequest + 13, // 13: api.APIService.getProof:input_type -> api.ProofRequest + 1, // 14: api.APIService.getMeta:output_type -> api.ChainMeta + 9, // 15: api.APIService.getCandidates:output_type -> api.CandidateResponse + 3, // 16: api.APIService.getCandidateByName:output_type -> api.Candidate + 10, // 17: api.APIService.getBucketsByCandidate:output_type -> api.BucketResponse + 10, // 18: api.APIService.getBuckets:output_type -> api.BucketResponse + 8, // 19: api.APIService.isHealth:output_type -> api.HealthCheckResponse + 12, // 20: api.APIService.getRawData:output_type -> api.RawDataResponse + 14, // 21: api.APIService.getProof:output_type -> api.ProofResponse + 14, // [14:22] is the sub-list for method output_type + 6, // [6:14] is the sub-list for method input_type + 6, // [6:6] is the sub-list for extension type_name + 6, // [6:6] is the sub-list for extension extendee + 0, // [0:6] is the sub-list for field type_name +} + +func init() { file_pb_api_api_proto_init() } +func file_pb_api_api_proto_init() { + if File_pb_api_api_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_pb_api_api_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ChainMeta); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pb_api_api_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Bucket); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pb_api_api_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Candidate); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pb_api_api_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetCandidatesRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pb_api_api_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetCandidateByNameRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pb_api_api_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetBucketsByCandidateRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pb_api_api_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetBucketsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pb_api_api_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HealthCheckResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pb_api_api_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CandidateResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pb_api_api_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BucketResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pb_api_api_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetRawDataRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pb_api_api_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RawDataResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pb_api_api_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ProofRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pb_api_api_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ProofResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_pb_api_api_proto_rawDesc, + NumEnums: 1, + NumMessages: 14, + NumExtensions: 0, + NumServices: 1, }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "pb/api/api.proto", + GoTypes: file_pb_api_api_proto_goTypes, + DependencyIndexes: file_pb_api_api_proto_depIdxs, + EnumInfos: file_pb_api_api_proto_enumTypes, + MessageInfos: file_pb_api_api_proto_msgTypes, + }.Build() + File_pb_api_api_proto = out.File + file_pb_api_api_proto_rawDesc = nil + file_pb_api_api_proto_goTypes = nil + file_pb_api_api_proto_depIdxs = nil } diff --git a/pb/api/api.proto b/pb/api/api.proto index f7440f8..408e281 100644 --- a/pb/api/api.proto +++ b/pb/api/api.proto @@ -38,8 +38,11 @@ service APIService { // health endpoint rpc isHealth(google.protobuf.Empty) returns (HealthCheckResponse) {} - //get raw data by height + // get raw data by height rpc getRawData(GetRawDataRequest) returns (RawDataResponse) {} + + // get proof for a given account + rpc getProof(ProofRequest) returns (ProofResponse) {} } message ChainMeta { @@ -117,4 +120,12 @@ message RawDataResponse { google.protobuf.Timestamp timestamp = 1; repeated election.Bucket buckets = 2; repeated election.Registration registrations = 3; +} + +message ProofRequest { + string account = 1; +} + +message ProofResponse { + string proof = 1; } \ No newline at end of file diff --git a/pb/api/api_grpc.pb.go b/pb/api/api_grpc.pb.go new file mode 100644 index 0000000..5654970 --- /dev/null +++ b/pb/api/api_grpc.pb.go @@ -0,0 +1,366 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. + +package api + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + emptypb "google.golang.org/protobuf/types/known/emptypb" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion7 + +// APIServiceClient is the client API for APIService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type APIServiceClient interface { + // get the blockchain meta data + GetMeta(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ChainMeta, error) + // get candidates + GetCandidates(ctx context.Context, in *GetCandidatesRequest, opts ...grpc.CallOption) (*CandidateResponse, error) + // get candidate by name + GetCandidateByName(ctx context.Context, in *GetCandidateByNameRequest, opts ...grpc.CallOption) (*Candidate, error) + // get buckets by candidate + GetBucketsByCandidate(ctx context.Context, in *GetBucketsByCandidateRequest, opts ...grpc.CallOption) (*BucketResponse, error) + // get Buckets + GetBuckets(ctx context.Context, in *GetBucketsRequest, opts ...grpc.CallOption) (*BucketResponse, error) + // health endpoint + IsHealth(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*HealthCheckResponse, error) + // get raw data by height + GetRawData(ctx context.Context, in *GetRawDataRequest, opts ...grpc.CallOption) (*RawDataResponse, error) + // get proof for a given account + GetProof(ctx context.Context, in *ProofRequest, opts ...grpc.CallOption) (*ProofResponse, error) +} + +type aPIServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewAPIServiceClient(cc grpc.ClientConnInterface) APIServiceClient { + return &aPIServiceClient{cc} +} + +func (c *aPIServiceClient) GetMeta(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ChainMeta, error) { + out := new(ChainMeta) + err := c.cc.Invoke(ctx, "/api.APIService/getMeta", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *aPIServiceClient) GetCandidates(ctx context.Context, in *GetCandidatesRequest, opts ...grpc.CallOption) (*CandidateResponse, error) { + out := new(CandidateResponse) + err := c.cc.Invoke(ctx, "/api.APIService/getCandidates", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *aPIServiceClient) GetCandidateByName(ctx context.Context, in *GetCandidateByNameRequest, opts ...grpc.CallOption) (*Candidate, error) { + out := new(Candidate) + err := c.cc.Invoke(ctx, "/api.APIService/getCandidateByName", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *aPIServiceClient) GetBucketsByCandidate(ctx context.Context, in *GetBucketsByCandidateRequest, opts ...grpc.CallOption) (*BucketResponse, error) { + out := new(BucketResponse) + err := c.cc.Invoke(ctx, "/api.APIService/getBucketsByCandidate", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *aPIServiceClient) GetBuckets(ctx context.Context, in *GetBucketsRequest, opts ...grpc.CallOption) (*BucketResponse, error) { + out := new(BucketResponse) + err := c.cc.Invoke(ctx, "/api.APIService/getBuckets", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *aPIServiceClient) IsHealth(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*HealthCheckResponse, error) { + out := new(HealthCheckResponse) + err := c.cc.Invoke(ctx, "/api.APIService/isHealth", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *aPIServiceClient) GetRawData(ctx context.Context, in *GetRawDataRequest, opts ...grpc.CallOption) (*RawDataResponse, error) { + out := new(RawDataResponse) + err := c.cc.Invoke(ctx, "/api.APIService/getRawData", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *aPIServiceClient) GetProof(ctx context.Context, in *ProofRequest, opts ...grpc.CallOption) (*ProofResponse, error) { + out := new(ProofResponse) + err := c.cc.Invoke(ctx, "/api.APIService/getProof", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// APIServiceServer is the server API for APIService service. +// All implementations must embed UnimplementedAPIServiceServer +// for forward compatibility +type APIServiceServer interface { + // get the blockchain meta data + GetMeta(context.Context, *emptypb.Empty) (*ChainMeta, error) + // get candidates + GetCandidates(context.Context, *GetCandidatesRequest) (*CandidateResponse, error) + // get candidate by name + GetCandidateByName(context.Context, *GetCandidateByNameRequest) (*Candidate, error) + // get buckets by candidate + GetBucketsByCandidate(context.Context, *GetBucketsByCandidateRequest) (*BucketResponse, error) + // get Buckets + GetBuckets(context.Context, *GetBucketsRequest) (*BucketResponse, error) + // health endpoint + IsHealth(context.Context, *emptypb.Empty) (*HealthCheckResponse, error) + // get raw data by height + GetRawData(context.Context, *GetRawDataRequest) (*RawDataResponse, error) + // get proof for a given account + GetProof(context.Context, *ProofRequest) (*ProofResponse, error) + mustEmbedUnimplementedAPIServiceServer() +} + +// UnimplementedAPIServiceServer must be embedded to have forward compatible implementations. +type UnimplementedAPIServiceServer struct { +} + +func (UnimplementedAPIServiceServer) GetMeta(context.Context, *emptypb.Empty) (*ChainMeta, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetMeta not implemented") +} +func (UnimplementedAPIServiceServer) GetCandidates(context.Context, *GetCandidatesRequest) (*CandidateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetCandidates not implemented") +} +func (UnimplementedAPIServiceServer) GetCandidateByName(context.Context, *GetCandidateByNameRequest) (*Candidate, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetCandidateByName not implemented") +} +func (UnimplementedAPIServiceServer) GetBucketsByCandidate(context.Context, *GetBucketsByCandidateRequest) (*BucketResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetBucketsByCandidate not implemented") +} +func (UnimplementedAPIServiceServer) GetBuckets(context.Context, *GetBucketsRequest) (*BucketResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetBuckets not implemented") +} +func (UnimplementedAPIServiceServer) IsHealth(context.Context, *emptypb.Empty) (*HealthCheckResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method IsHealth not implemented") +} +func (UnimplementedAPIServiceServer) GetRawData(context.Context, *GetRawDataRequest) (*RawDataResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetRawData not implemented") +} +func (UnimplementedAPIServiceServer) GetProof(context.Context, *ProofRequest) (*ProofResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetProof not implemented") +} +func (UnimplementedAPIServiceServer) mustEmbedUnimplementedAPIServiceServer() {} + +// UnsafeAPIServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to APIServiceServer will +// result in compilation errors. +type UnsafeAPIServiceServer interface { + mustEmbedUnimplementedAPIServiceServer() +} + +func RegisterAPIServiceServer(s *grpc.Server, srv APIServiceServer) { + s.RegisterService(&_APIService_serviceDesc, srv) +} + +func _APIService_GetMeta_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(emptypb.Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(APIServiceServer).GetMeta(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/api.APIService/GetMeta", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(APIServiceServer).GetMeta(ctx, req.(*emptypb.Empty)) + } + return interceptor(ctx, in, info, handler) +} + +func _APIService_GetCandidates_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetCandidatesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(APIServiceServer).GetCandidates(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/api.APIService/GetCandidates", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(APIServiceServer).GetCandidates(ctx, req.(*GetCandidatesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _APIService_GetCandidateByName_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetCandidateByNameRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(APIServiceServer).GetCandidateByName(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/api.APIService/GetCandidateByName", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(APIServiceServer).GetCandidateByName(ctx, req.(*GetCandidateByNameRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _APIService_GetBucketsByCandidate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetBucketsByCandidateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(APIServiceServer).GetBucketsByCandidate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/api.APIService/GetBucketsByCandidate", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(APIServiceServer).GetBucketsByCandidate(ctx, req.(*GetBucketsByCandidateRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _APIService_GetBuckets_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetBucketsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(APIServiceServer).GetBuckets(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/api.APIService/GetBuckets", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(APIServiceServer).GetBuckets(ctx, req.(*GetBucketsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _APIService_IsHealth_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(emptypb.Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(APIServiceServer).IsHealth(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/api.APIService/IsHealth", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(APIServiceServer).IsHealth(ctx, req.(*emptypb.Empty)) + } + return interceptor(ctx, in, info, handler) +} + +func _APIService_GetRawData_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetRawDataRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(APIServiceServer).GetRawData(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/api.APIService/GetRawData", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(APIServiceServer).GetRawData(ctx, req.(*GetRawDataRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _APIService_GetProof_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ProofRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(APIServiceServer).GetProof(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/api.APIService/GetProof", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(APIServiceServer).GetProof(ctx, req.(*ProofRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _APIService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "api.APIService", + HandlerType: (*APIServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "getMeta", + Handler: _APIService_GetMeta_Handler, + }, + { + MethodName: "getCandidates", + Handler: _APIService_GetCandidates_Handler, + }, + { + MethodName: "getCandidateByName", + Handler: _APIService_GetCandidateByName_Handler, + }, + { + MethodName: "getBucketsByCandidate", + Handler: _APIService_GetBucketsByCandidate_Handler, + }, + { + MethodName: "getBuckets", + Handler: _APIService_GetBuckets_Handler, + }, + { + MethodName: "isHealth", + Handler: _APIService_IsHealth_Handler, + }, + { + MethodName: "getRawData", + Handler: _APIService_GetRawData_Handler, + }, + { + MethodName: "getProof", + Handler: _APIService_GetProof_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "pb/api/api.proto", +} diff --git a/server/dummy_server.go b/server/dummy_server.go index 5fdfd42..16b58d9 100644 --- a/server/dummy_server.go +++ b/server/dummy_server.go @@ -11,12 +11,14 @@ package server import ( + "encoding/hex" "log" "net" "strconv" "github.com/golang/protobuf/ptypes/empty" - + "github.com/iotexproject/iotex-address/address" + "github.com/pkg/errors" "go.uber.org/zap" "go.uber.org/zap/zapcore" "golang.org/x/net/context" @@ -24,6 +26,7 @@ import ( "google.golang.org/grpc/reflection" "github.com/iotexproject/iotex-election/pb/api" + "github.com/iotexproject/iotex-election/votesync" ) // DummyServer defines the interface of the ranking dummy server implementation @@ -35,12 +38,14 @@ type DummyServer interface { // server implements api.APIServiceServer. type dummyServer struct { + api.UnimplementedAPIServiceServer port int grpcServer *grpc.Server + vs *votesync.VoteSync } // NewDummyServer returns an implementation of ranking dummy server -func NewDummyServer(port int) (DummyServer, error) { +func NewDummyServer(port int, vs *votesync.VoteSync) (DummyServer, error) { zapCfg := zap.NewDevelopmentConfig() zapCfg.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder zapCfg.Level.SetLevel(zap.InfoLevel) @@ -51,6 +56,7 @@ func NewDummyServer(port int) (DummyServer, error) { zap.ReplaceGlobals(l) s := &dummyServer{ port: port, + vs: vs, } s.grpcServer = grpc.NewServer() api.RegisterAPIServiceServer(s.grpcServer, s) @@ -67,6 +73,11 @@ func (s *dummyServer) Start(ctx context.Context) error { zap.L().Error("Ranking dummpy server failed to listen port.", zap.Error(err)) return err } + go func() { + if s.vs != nil { + s.vs.Start(ctx) + } + }() go func() { if err := s.grpcServer.Serve(lis); err != nil { zap.L().Fatal("Failed to serve", zap.Error(err)) @@ -78,6 +89,9 @@ func (s *dummyServer) Start(ctx context.Context) error { func (s *dummyServer) Stop(ctx context.Context) error { zap.L().Info("Dummpy server is stopping") s.grpcServer.Stop() + if s.vs != nil { + s.vs.Stop(ctx) + } return nil } @@ -120,3 +134,23 @@ func (s *dummyServer) GetRawData(ctx context.Context, request *api.GetRawDataReq zap.L().Info("Dummpy server calls GetRawData func") return nil, nil } + +func (s *dummyServer) GetProof(ctx context.Context, request *api.ProofRequest) (*api.ProofResponse, error) { + zap.L().Info("Dummpy server calls GetProof func") + if s.vs == nil { + return nil, errors.New("no vote sync server") + } + addr, err := address.FromString(request.Account) + if err != nil { + return nil, errors.Wrapf(err, "failed to cast account %s", request.Account) + } + proof, err := s.vs.ProofForAccount(addr) + if err != nil { + return nil, err + } + if proof == nil { + return nil, nil + } + + return &api.ProofResponse{Proof: hex.EncodeToString(proof)}, nil +} diff --git a/server/dummy_server_test.go b/server/dummy_server_test.go index 4aca86d..86cc6df 100644 --- a/server/dummy_server_test.go +++ b/server/dummy_server_test.go @@ -19,7 +19,7 @@ import ( func TestStartDummyServer(t *testing.T) { r := require.New(t) - s, err := NewDummyServer(32223) + s, err := NewDummyServer(32223, nil) r.NoError(err) r.True(s != nil) ctx := context.Background() diff --git a/server/server.go b/server/server.go index bba83c8..cbf12e8 100644 --- a/server/server.go +++ b/server/server.go @@ -12,7 +12,6 @@ package server import ( "encoding/hex" - "errors" "math" "math/big" "net" @@ -21,7 +20,8 @@ import ( "github.com/golang/protobuf/ptypes" "github.com/golang/protobuf/ptypes/empty" - + "github.com/iotexproject/iotex-address/address" + "github.com/pkg/errors" "go.uber.org/zap" "golang.org/x/net/context" "google.golang.org/grpc" @@ -33,6 +33,7 @@ import ( electionpb "github.com/iotexproject/iotex-election/pb/election" "github.com/iotexproject/iotex-election/types" "github.com/iotexproject/iotex-election/util" + "github.com/iotexproject/iotex-election/votesync" ) // Config defines the config for server @@ -53,15 +54,17 @@ type Server interface { // server implements api.APIServiceServer. type server struct { + api.UnimplementedAPIServiceServer port int electionCommittee committee.Committee grpcServer *grpc.Server selfStakingThreshold *big.Int scoreThreshold *big.Int + vs *votesync.VoteSync } // NewServer returns an implementation of ranking server -func NewServer(cfg *Config) (Server, error) { +func NewServer(cfg *Config, vs *votesync.VoteSync) (Server, error) { archive, err := committee.NewArchive(cfg.DB.DBPath, cfg.DB.NumOfRetries, cfg.Committee.GravityChainStartHeight, cfg.Committee.GravityChainHeightInterval) if err != nil { return nil, err @@ -72,17 +75,18 @@ func NewServer(cfg *Config) (Server, error) { } scoreThreshold, ok := new(big.Int).SetString(cfg.ScoreThreshold, 10) if !ok { - return nil, errors.New("Invalid score threshold") + return nil, errors.New("invalid score threshold") } selfStakingThreshold, ok := new(big.Int).SetString(cfg.SelfStakingThreshold, 10) if !ok { - return nil, errors.New("Invalid self staking threshold") + return nil, errors.New("invalid self staking threshold") } s := &server{ electionCommittee: c, port: cfg.Port, scoreThreshold: scoreThreshold, selfStakingThreshold: selfStakingThreshold, + vs: vs, } s.grpcServer = grpc.NewServer() api.RegisterAPIServiceServer(s.grpcServer, s) @@ -100,6 +104,11 @@ func (s *server) Start(ctx context.Context) error { zap.L().Error("Ranking server failed to listen port.", zap.Error(err)) return err } + go func() { + if s.vs != nil { + s.vs.Start(ctx) + } + }() go func() { if err := s.grpcServer.Serve(lis); err != nil { zap.L().Fatal("Failed to serve", zap.Error(err)) @@ -110,6 +119,9 @@ func (s *server) Start(ctx context.Context) error { func (s *server) Stop(ctx context.Context) error { s.grpcServer.Stop() + if s.vs != nil { + s.vs.Stop(ctx) + } return s.electionCommittee.Stop(ctx) } @@ -255,7 +267,7 @@ func (s *server) GetBucketsByCandidate(ctx context.Context, request *api.GetBuck return nil, errors.New("invalid candidate name") } if votes == nil { - return nil, errors.New("No buckets for the candidate") + return nil, errors.New("no buckets for the candidate") } offset := request.Offset if int(offset) >= len(votes) { @@ -300,7 +312,7 @@ func (s *server) GetBuckets(ctx context.Context, request *api.GetBucketsRequest) } votes := result.Votes() if votes == nil { - return nil, errors.New("No buckets available") + return nil, errors.New("no buckets available") } offset := request.Offset if int(offset) >= len(votes) { @@ -349,3 +361,22 @@ func (s *server) toRawDataResponse(mintTime time.Time, regs []*types.Registratio response.Timestamp = t return response, nil } + +func (s *server) GetProof(ctx context.Context, request *api.ProofRequest) (*api.ProofResponse, error) { + if s.vs == nil { + return nil, errors.New("no vote sync server") + } + addr, err := address.FromString(request.Account) + if err != nil { + return nil, errors.Wrapf(err, "failed to cast address %s", request.Account) + } + proof, err := s.vs.ProofForAccount(addr) + if err != nil { + return nil, err + } + if proof == nil { + return nil, nil + } + + return &api.ProofResponse{Proof: hex.EncodeToString(proof)}, nil +} diff --git a/server/servermix.go b/server/servermix.go index 24b0ad4..266c430 100644 --- a/server/servermix.go +++ b/server/servermix.go @@ -7,8 +7,7 @@ import ( ) type ServerMix struct { - ess Server - voteSync *votesync.VoteSync + ess Server } type MixConfig struct { @@ -20,45 +19,35 @@ type MixConfig struct { } func NewServerMix(mCfg MixConfig) (*ServerMix, error) { - var ess Server var err error - if mCfg.DummyServerPort != 0 { - ess, err = NewDummyServer(mCfg.DummyServerPort) + var vs *votesync.VoteSync + if mCfg.EnableVoteSync { + vs, err = votesync.NewVoteSync(mCfg.VoteSync) if err != nil { return nil, err } - zap.L().Info("New dummy server created") - } else { - ess, err = NewServer(&mCfg.ElectionConfig) + } + var ess Server + if mCfg.DummyServerPort != 0 { + ess, err = NewDummyServer(mCfg.DummyServerPort, vs) if err != nil { return nil, err } - } - var vs *votesync.VoteSync - if mCfg.EnableVoteSync { - vs, err = votesync.NewVoteSync(mCfg.VoteSync) + zap.L().Info("New dummy server created") + } else { + ess, err = NewServer(&mCfg.ElectionConfig, vs) if err != nil { return nil, err } } - return &ServerMix{ - ess: ess, - voteSync: vs, - }, nil + return &ServerMix{ess: ess}, nil } func (sm *ServerMix) Start(ctx context.Context) error { - if err := sm.ess.Start(ctx); err != nil { - return err - } - if sm.voteSync != nil { - sm.voteSync.Start(ctx) - } - return nil + return sm.ess.Start(ctx) } func (sm *ServerMix) Stop(ctx context.Context) error { - sm.voteSync.Stop(ctx) return sm.ess.Stop(ctx) } diff --git a/votesync/agentcontract.go b/votesync/agentcontract.go new file mode 100644 index 0000000..28a4c0e --- /dev/null +++ b/votesync/agentcontract.go @@ -0,0 +1,63 @@ +package votesync + +import ( + "context" + "math/big" + "strings" + + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" + "github.com/iotexproject/iotex-address/address" + "github.com/iotexproject/iotex-antenna-go/v2/iotex" + "github.com/iotexproject/iotex-election/contract" + "github.com/iotexproject/iotex-election/util" +) + +type agentContract struct { + contract iotex.Contract + addr common.Address +} + +func NewAgentContract(cli iotex.AuthedClient, addr address.Address) (*agentContract, error) { + agentABI, err := abi.JSON(strings.NewReader(contract.AgentABI)) + if err != nil { + return nil, err + } + return &agentContract{contract: cli.Contract(addr, agentABI), addr: common.BytesToAddress(addr.Bytes())}, nil +} + +func (ac *agentContract) Address() common.Address { + return ac.addr +} + +func (ac *agentContract) Claimed(acct address.Address) (*big.Int, *big.Int, bool, error) { + data, err := ac.contract.Read("claimed", acct).Call(context.Background()) + if err != nil { + return nil, nil, false, err + } + ret, err := data.Unmarshal() + if err != nil { + return nil, nil, false, err + } + cycle, err := util.ToBigInt(ret[0]) + if err != nil { + return nil, nil, false, err + } + size, err := util.ToBigInt(ret[1]) + if err != nil { + return nil, nil, false, err + } + return cycle, size, ret[2].(bool), nil +} + +func (ac *agentContract) Digest(power *big.Int, cycle *big.Int) ([]byte, error) { + data, err := ac.contract.Read("digest", power, cycle).Call(context.Background()) + if err != nil { + return nil, err + } + ret, err := data.Unmarshal() + if err != nil { + return nil, err + } + return ret[0].([]byte), nil +} diff --git a/votesync/brokercontract.go b/votesync/brokercontract.go new file mode 100644 index 0000000..f75f667 --- /dev/null +++ b/votesync/brokercontract.go @@ -0,0 +1,56 @@ +package votesync + +import ( + "context" + "math/big" + "strings" + + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/iotexproject/iotex-address/address" + "github.com/iotexproject/iotex-antenna-go/v2/iotex" + "github.com/iotexproject/iotex-antenna-go/v2/utils/unit" + "github.com/iotexproject/iotex-antenna-go/v2/utils/wait" + "github.com/iotexproject/iotex-election/contract" + "github.com/iotexproject/iotex-election/util" +) + +type brokerContract struct { + contract iotex.Contract + batchSize uint64 +} + +func NewBrokerContract(cli iotex.AuthedClient, addr address.Address, batchSize uint8) (*brokerContract, error) { + brokerABI, err := abi.JSON(strings.NewReader(contract.BrokerABI)) + if err != nil { + return nil, err + } + return &brokerContract{contract: cli.Contract(addr, brokerABI), batchSize: uint64(batchSize)}, nil +} + +func (bc *brokerContract) Reset() error { + caller := bc.contract.Execute("reset").SetGasPrice(big.NewInt(int64(1 * unit.Qev))).SetGasLimit(5000000) + return wait.Wait(context.Background(), caller) +} + +func (bc *brokerContract) NextBidToSettle() (uint64, error) { + d, err := bc.contract.Read("nextBidToSettle").Call(context.Background()) + if err != nil { + return 0, err + } + ret, err := d.Unmarshal() + if err != nil { + return 0, err + } + nextBidToSettle, err := util.ToBigInt(ret[0]) + if err != nil { + return 0, err + } + return nextBidToSettle.Uint64(), nil +} + +func (bc *brokerContract) Settle() error { + caller := bc.contract.Execute( + "settle", big.NewInt(0).SetUint64(bc.batchSize)). + SetGasPrice(big.NewInt(int64(1 * unit.Qev))).SetGasLimit(5000000) + return wait.Wait(context.Background(), caller) +} diff --git a/votesync/clerkcontract.go b/votesync/clerkcontract.go new file mode 100644 index 0000000..8df0140 --- /dev/null +++ b/votesync/clerkcontract.go @@ -0,0 +1,31 @@ +package votesync + +import ( + "context" + "math/big" + "strings" + + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/iotexproject/iotex-address/address" + "github.com/iotexproject/iotex-antenna-go/v2/iotex" + "github.com/iotexproject/iotex-antenna-go/v2/utils/unit" + "github.com/iotexproject/iotex-antenna-go/v2/utils/wait" + "github.com/iotexproject/iotex-election/contract" +) + +type clerkContract struct { + contract iotex.Contract +} + +func NewClerkContract(cli iotex.AuthedClient, addr address.Address) (*clerkContract, error) { + clerkABI, err := abi.JSON(strings.NewReader(contract.ClerkABI)) + if err != nil { + return nil, err + } + return &clerkContract{contract: cli.Contract(addr, clerkABI)}, nil +} + +func (cc *clerkContract) Claim() error { + caller := cc.contract.Execute("claim").SetGasPrice(big.NewInt(int64(1 * unit.Qev))).SetGasLimit(5000000) + return wait.Wait(context.Background(), caller) +} diff --git a/votesync/discord.go b/votesync/discord.go new file mode 100644 index 0000000..b8f266e --- /dev/null +++ b/votesync/discord.go @@ -0,0 +1,43 @@ +package votesync + +import "github.com/bwmarrin/discordgo" + +type discord struct { + botToken string + channelID string + newCycleMsg string + reminderMsg string + reminded bool +} + +func (d *discord) sendMessage(msg string) error { + if d.botToken == "" || msg == "" { + return nil + } + + dg, err := discordgo.New("Bot " + d.botToken) + if err != nil { + return err + } + if err := dg.Open(); err != nil { + return err + } + defer dg.Close() + + _, err = dg.ChannelMessageSend(d.channelID, msg) + return err +} + +func (d *discord) SendNewCycleMessage() error { + d.reminded = false + return d.sendMessage(d.newCycleMsg) +} + +func (d *discord) SendReminder() error { + d.reminded = true + return d.sendMessage(d.reminderMsg) +} + +func (d *discord) Reminded() bool { + return d.reminded +} diff --git a/votesync/iotexclient.go b/votesync/iotexclient.go new file mode 100644 index 0000000..9946ccc --- /dev/null +++ b/votesync/iotexclient.go @@ -0,0 +1,53 @@ +package votesync + +import ( + "context" + "time" + + "github.com/golang/protobuf/ptypes" + "github.com/iotexproject/iotex-proto/golang/iotexapi" + "github.com/pkg/errors" +) + +type iotexClient struct { + client iotexapi.APIServiceClient +} + +func NewIoTeXClient(client iotexapi.APIServiceClient) *iotexClient { + return &iotexClient{client: client} +} + +func (ic *iotexClient) BlockTime(h uint64) (time.Time, error) { + resp, err := ic.client.GetBlockMetas(context.Background(), &iotexapi.GetBlockMetasRequest{ + Lookup: &iotexapi.GetBlockMetasRequest_ByIndex{ + ByIndex: &iotexapi.GetBlockMetasByIndexRequest{ + Start: h, Count: 1, + }, + }, + }) + if err != nil { + return time.Now(), errors.Wrapf(err, "failed to fetch block meta %v", h) + } + bms := resp.GetBlkMetas() + if len(bms) != 1 { + return time.Now(), errors.Wrapf(err, "asked 1 block, but got none-1 value %v", h) + } + ts := bms[0].GetTimestamp() + bt, err := ptypes.Timestamp(ts) + if err != nil { + return time.Now(), errors.Wrapf(err, "failed to parse timestamp in blockmeta %v", h) + } + return bt, nil +} + +func (ic *iotexClient) Tip() (uint64, error) { + response, err := ic.client.GetChainMeta( + context.Background(), + &iotexapi.GetChainMetaRequest{}, + ) + if err != nil { + return 0, err + } + + return response.ChainMeta.Height, nil +} diff --git a/votesync/rotatableweightedvps.go b/votesync/rotatableweightedvps.go new file mode 100644 index 0000000..a8e2336 --- /dev/null +++ b/votesync/rotatableweightedvps.go @@ -0,0 +1,144 @@ +package votesync + +import ( + "context" + "math/big" + "strings" + + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" + "github.com/iotexproject/iotex-address/address" + "github.com/iotexproject/iotex-antenna-go/v2/iotex" + "github.com/iotexproject/iotex-antenna-go/v2/utils/unit" + "github.com/iotexproject/iotex-antenna-go/v2/utils/wait" + "github.com/iotexproject/iotex-election/contract" + "github.com/iotexproject/iotex-election/util" + "github.com/pkg/errors" +) + +type rwvps struct { + batchSize int + contract iotex.Contract +} + +func NewRotatableWeightedVPS(cli iotex.AuthedClient, addr address.Address, batchSize uint8) (*rwvps, error) { + vpsABI, err := abi.JSON(strings.NewReader(contract.RotatableVPSABI)) + if err != nil { + return nil, err + } + return &rwvps{contract: cli.Contract(addr, vpsABI), batchSize: int(batchSize)}, nil +} + +func (vps *rwvps) ViewID() (*big.Int, error) { + d, err := vps.contract.Read("viewID").Call(context.Background()) + if err != nil { + return nil, err + } + ret, err := d.Unmarshal() + if err != nil { + return nil, err + } + return util.ToBigInt(ret[0]) +} + +func (vps *rwvps) InactiveViewID() (*big.Int, error) { + d, err := vps.contract.Read("inactiveViewID").Call(context.Background()) + if err != nil { + return nil, err + } + ret, err := d.Unmarshal() + if err != nil { + return nil, err + } + return util.ToBigInt(ret[0]) +} + +func (vps *rwvps) Rotate(viewID *big.Int) error { + caller := vps.contract.Execute("rotate", viewID). + SetGasPrice(big.NewInt(int64(1 * unit.Qev))).SetGasLimit(4000000) + + return wait.Wait(context.Background(), caller) +} + +func (vps *rwvps) UpdateVotingPowers(addrs []common.Address, weights []*big.Int) error { + if len(addrs) != len(weights) { + return errors.Errorf("addrs and weights are of different lengths, %d vs %d", len(addrs), len(weights)) + } + if len(addrs) == 0 { + return vps.updateVotingPowers(addrs, weights) + } + paginationSize := vps.batchSize / 5 + as := []common.Address{} + ws := []*big.Int{} + for i := range addrs { + as = append(as, addrs[i]) + ws = append(ws, weights[i]) + if i%paginationSize == 0 { + if err := vps.updateVotingPowers(as, ws); err != nil { + return err + } + as = []common.Address{} + ws = []*big.Int{} + } + } + if len(as) > 0 { + return vps.updateVotingPowers(as, ws) + } + return nil +} + +func (vps *rwvps) updateVotingPowers(addrs []common.Address, weights []*big.Int) error { + caller := vps.contract.Execute("updateVotingPowers", addrs, weights). + SetGasPrice(big.NewInt(int64(1 * unit.Qev))).SetGasLimit(7000000) + return wait.Wait(context.Background(), caller) +} + +func (vps *rwvps) TotalPower() (*big.Int, error) { + tpResult, err := vps.contract.Read("totalPower").Call(context.Background()) + if err != nil { + return nil, err + } + ret, err := tpResult.Unmarshal() + if err != nil { + return nil, err + } + + return util.ToBigInt(ret[0]) +} + +func (vps *rwvps) VoterPowers() (map[common.Address]*big.Int, error) { + offset := 0 + votingPowers := make(map[common.Address]*big.Int) + for { + d, err := vps.contract.Read("voters", offset, vps.batchSize).Call(context.Background()) + if err != nil { + return nil, err + } + ret, err := d.Unmarshal() + if err != nil { + return nil, err + } + voters := ret[0].([]common.Address) + d, err = vps.contract.Read("powersOf", voters).Call(context.Background()) + if err != nil { + return nil, err + } + ret, err = d.Unmarshal() + if err != nil { + return nil, err + } + zero := big.NewInt(0) + powers := ret[0].([]*big.Int) + for i := range powers { + if powers[i].Cmp(zero) != 0 { + votingPowers[voters[i]] = powers[i] + } + } + if len(voters) < vps.batchSize { + break + } + offset += vps.batchSize + } + + return votingPowers, nil +} diff --git a/votesync/vitacontract.go b/votesync/vitacontract.go new file mode 100644 index 0000000..16c35dd --- /dev/null +++ b/votesync/vitacontract.go @@ -0,0 +1,74 @@ +package votesync + +import ( + "context" + "math/big" + "strings" + + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" + "github.com/iotexproject/iotex-address/address" + "github.com/iotexproject/iotex-antenna-go/v2/iotex" + "github.com/iotexproject/iotex-election/contract" + "github.com/iotexproject/iotex-election/util" +) + +type vitaContract struct { + contract iotex.Contract +} + +func NewVitaContract(cli iotex.AuthedClient, addr address.Address) (*vitaContract, error) { + vitaABI, err := abi.JSON(strings.NewReader(contract.VitaABI)) + if err != nil { + return nil, err + } + return &vitaContract{contract: cli.Contract(addr, vitaABI)}, nil +} + +func (vc *vitaContract) readAddress(fn string) (address.Address, error) { + d, err := vc.contract.Read(fn).Call(context.Background()) + if err != nil { + return common.Address{}, err + } + ret, err := d.Unmarshal() + if err != nil { + return common.Address{}, err + } + addr, err := util.ToEtherAddress(ret[0]) + if err != nil { + return common.Address{}, err + } + return address.FromBytes(addr.Bytes()) +} + +func (vc *vitaContract) readViewID(name string) (*big.Int, error) { + d, err := vc.contract.Read("lastDonationPoolClaimViewID").Call(context.Background()) + if err != nil { + return nil, err + } + ret, err := d.Unmarshal() + if err != nil { + return nil, err + } + return util.ToBigInt(ret[0]) +} + +func (vc *vitaContract) VPS() (address.Address, error) { + return vc.readAddress("vps") +} + +func (vc *vitaContract) DonationPoolAddress() (address.Address, error) { + return vc.readAddress("donationPoolAddress") +} + +func (vc *vitaContract) RewardPoolAddress() (address.Address, error) { + return vc.readAddress("rewardPoolAddress") +} + +func (vc *vitaContract) LastDonationPoolClaimViewID() (*big.Int, error) { + return vc.readViewID("lastDonationPoolClaimViewID") +} + +func (vc *vitaContract) LastRewardPoolClaimViewID() (*big.Int, error) { + return vc.readViewID("lastRewardPoolClaimViewID") +} diff --git a/votesync/votefetcher.go b/votesync/votefetcher.go new file mode 100644 index 0000000..459dc7a --- /dev/null +++ b/votesync/votefetcher.go @@ -0,0 +1,153 @@ +package votesync + +import ( + "context" + "strconv" + + "github.com/cenkalti/backoff" + "github.com/pkg/errors" + "go.uber.org/zap" + "google.golang.org/protobuf/proto" + + "github.com/iotexproject/iotex-proto/golang/iotexapi" + "github.com/iotexproject/iotex-proto/golang/iotextypes" +) + +// VoteFetcher defines fields used to fetch votes +type VoteFetcher struct { + iotexAPI iotexapi.APIServiceClient +} + +func (fetcher *VoteFetcher) FetchBucketsByHeight(ctx context.Context, h uint64) (*iotextypes.VoteBucketList, *iotextypes.CandidateListV2, error) { + var ( + ret1 *iotextypes.VoteBucketList + ret2 *iotextypes.CandidateListV2 + err error + ) + nerr := backoff.Retry(func() error { + ret1, err = getAllStakingBuckets(ctx, fetcher.iotexAPI, h) + if err != nil { + return err + } + ret2, err = getAllStakingCandidates(ctx, fetcher.iotexAPI, h) + return err + }, backoff.NewExponentialBackOff()) + if nerr != nil { + zap.L().Error( + "failed to fetch vote result by height", + zap.Error(nerr), + zap.Uint64("height", h), + ) + } + return ret1, ret2, nerr +} + +func getAllStakingBuckets(ctx context.Context, chainClient iotexapi.APIServiceClient, height uint64) (voteBucketListAll *iotextypes.VoteBucketList, err error) { + voteBucketListAll = &iotextypes.VoteBucketList{} + for i := uint32(0); ; i++ { + offset := i * readBucketsLimit + size := uint32(readBucketsLimit) + voteBucketList, err := getStakingBuckets(ctx, chainClient, offset, size, height) + if err != nil { + return nil, errors.Wrap(err, "failed to get bucket") + } + voteBucketListAll.Buckets = append(voteBucketListAll.Buckets, voteBucketList.Buckets...) + if len(voteBucketList.Buckets) < readBucketsLimit { + break + } + } + return +} + +func getAllStakingCandidates(ctx context.Context, chainClient iotexapi.APIServiceClient, height uint64) (candidateListAll *iotextypes.CandidateListV2, err error) { + candidateListAll = &iotextypes.CandidateListV2{} + for i := uint32(0); ; i++ { + offset := i * readCandidatesLimit + size := uint32(readCandidatesLimit) + candidateList, err := getStakingCandidates(ctx, chainClient, offset, size, height) + if err != nil { + return nil, errors.Wrap(err, "failed to get candidates") + } + candidateListAll.Candidates = append(candidateListAll.Candidates, candidateList.Candidates...) + if len(candidateList.Candidates) < readCandidatesLimit { + break + } + } + return +} + +// getStakingBuckets get specific buckets by height +func getStakingBuckets(ctx context.Context, chainClient iotexapi.APIServiceClient, offset, limit uint32, height uint64) (voteBucketList *iotextypes.VoteBucketList, err error) { + methodName, err := proto.Marshal(&iotexapi.ReadStakingDataMethod{ + Method: iotexapi.ReadStakingDataMethod_BUCKETS, + }) + if err != nil { + return nil, err + } + arg, err := proto.Marshal(&iotexapi.ReadStakingDataRequest{ + Request: &iotexapi.ReadStakingDataRequest_Buckets{ + Buckets: &iotexapi.ReadStakingDataRequest_VoteBuckets{ + Pagination: &iotexapi.PaginationParam{ + Offset: offset, + Limit: limit, + }, + }, + }, + }) + if err != nil { + return nil, err + } + readStateRequest := &iotexapi.ReadStateRequest{ + ProtocolID: []byte(protocolID), + MethodName: methodName, + Arguments: [][]byte{arg}, + Height: strconv.FormatUint(height, 10), + } + readStateRes, err := chainClient.ReadState(ctx, readStateRequest) + if err != nil { + return + } + voteBucketList = &iotextypes.VoteBucketList{} + if err := proto.Unmarshal(readStateRes.GetData(), voteBucketList); err != nil { + return nil, errors.Wrap(err, "failed to unmarshal VoteBucketList") + } + return +} + +// getStakingCandidates get specific candidates by height +func getStakingCandidates(ctx context.Context, chainClient iotexapi.APIServiceClient, offset, limit uint32, height uint64) (candidateList *iotextypes.CandidateListV2, err error) { + methodName, err := proto.Marshal(&iotexapi.ReadStakingDataMethod{ + Method: iotexapi.ReadStakingDataMethod_CANDIDATES, + }) + if err != nil { + return nil, err + } + arg, err := proto.Marshal(&iotexapi.ReadStakingDataRequest{ + Request: &iotexapi.ReadStakingDataRequest_Candidates_{ + Candidates: &iotexapi.ReadStakingDataRequest_Candidates{ + Pagination: &iotexapi.PaginationParam{ + Offset: offset, + Limit: limit, + }, + }, + }, + }) + if err != nil { + return nil, err + } + readStateRequest := &iotexapi.ReadStateRequest{ + ProtocolID: []byte(protocolID), + MethodName: methodName, + Arguments: [][]byte{arg}, + Height: strconv.FormatUint(height, 10), + } + readStateRes, err := chainClient.ReadState(ctx, readStateRequest) + if err != nil { + return + } + candidateList = &iotextypes.CandidateListV2{} + if err := proto.Unmarshal(readStateRes.GetData(), candidateList); err != nil { + return nil, errors.Wrap(err, "failed to unmarshal VoteBucketList") + } + return +} diff --git a/votesync/votesync.go b/votesync/votesync.go index 05173c0..7b3c2e9 100644 --- a/votesync/votesync.go +++ b/votesync/votesync.go @@ -6,16 +6,9 @@ import ( "fmt" "math" "math/big" - "strconv" - "strings" "time" - "github.com/bwmarrin/discordgo" - "github.com/cenkalti/backoff" - "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" - "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/ptypes" grpc_retry "github.com/grpc-ecosystem/go-grpc-middleware/retry" "github.com/pkg/errors" "go.uber.org/zap" @@ -25,13 +18,8 @@ import ( "github.com/iotexproject/iotex-address/address" "github.com/iotexproject/iotex-antenna-go/v2/account" "github.com/iotexproject/iotex-antenna-go/v2/iotex" - "github.com/iotexproject/iotex-antenna-go/v2/utils/unit" - "github.com/iotexproject/iotex-antenna-go/v2/utils/wait" - "github.com/iotexproject/iotex-election/contract" "github.com/iotexproject/iotex-proto/golang/iotexapi" "github.com/iotexproject/iotex-proto/golang/iotextypes" - - "github.com/iotexproject/iotex-election/util" ) const _viewIDOffsite = 10000000 @@ -44,18 +32,18 @@ const ( readCandidatesLimit = 20000 ) +var _fixedAdhocPower = big.NewInt(1) + //VoteSync defines fields used in VoteSync type VoteSync struct { - service iotex.AuthedClient - iotexAPI iotexapi.APIServiceClient - vpsContract iotex.Contract - brokerContract iotex.Contract - clerkContract iotex.Contract - discordBotToken string - discordChannelID string - discordMsg string - discordReminder string - discordReminded bool + agentContract *agentContract + votingPowers *VotingPowers + client *iotexClient + fetcher *VoteFetcher + vpsContract *rwvps + brokerContract *brokerContract + clerkContract *clerkContract + discord *discord lastViewHeight uint64 lastViewTimestamp time.Time lastUpdateHeight uint64 @@ -63,8 +51,6 @@ type VoteSync struct { lastClerkUpdateHeight uint64 lastUpdateTimestamp time.Time timeInternal time.Duration - paginationSize uint8 - brokerPaginationSize uint8 lastNativeEphoch uint64 tempLastNativeEphoch uint64 terminate chan bool @@ -89,9 +75,11 @@ type Config struct { DiscordChannelID string `yaml:"discordChannelID"` DiscordMsg string `yaml:"discordMsg"` DiscordReminder string `yaml:"discordReminder"` - DardaenllesHeight uint64 `yaml:"dardanellesHeight"` + DardanellesHeight uint64 `yaml:"dardanellesHeight"` FairBankHeight uint64 `yaml:"fairbankHeight"` NativeCommitteeInitHeight uint64 `yaml:"nativeCommitteeInitHeight"` + EnableAgentMode bool `yaml:"enableAgentMode"` + AgentContractAddress string `yaml:"agentContractAddress"` } //WeightedVote defines voter and votes for weighted vote @@ -116,21 +104,17 @@ func NewVoteSync(cfg Config) (*VoteSync, error) { grpc_retry.WithBackoff(grpc_retry.BackoffLinear(100 * time.Second)), grpc_retry.WithMax(3), } - var conn *grpc.ClientConn - var err error + dialOpts := []grpc.DialOption{ + grpc.WithBlock(), + grpc.WithStreamInterceptor(grpc_retry.StreamClientInterceptor(opts...)), + grpc.WithUnaryInterceptor(grpc_retry.UnaryClientInterceptor(opts...)), + } if cfg.IoTeXAPISecure { - conn, err = grpc.DialContext(ctx, cfg.IoTeXAPI, - grpc.WithBlock(), - grpc.WithStreamInterceptor(grpc_retry.StreamClientInterceptor(opts...)), - grpc.WithUnaryInterceptor(grpc_retry.UnaryClientInterceptor(opts...)), - grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{}))) + dialOpts = append(dialOpts, grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{}))) } else { - conn, err = grpc.DialContext(ctx, cfg.IoTeXAPI, - grpc.WithBlock(), - grpc.WithStreamInterceptor(grpc_retry.StreamClientInterceptor(opts...)), - grpc.WithUnaryInterceptor(grpc_retry.UnaryClientInterceptor(opts...)), - grpc.WithInsecure()) + dialOpts = append(dialOpts, grpc.WithInsecure()) } + conn, err := grpc.DialContext(ctx, cfg.IoTeXAPI, dialOpts...) if err != nil { return nil, err } @@ -139,85 +123,41 @@ func NewVoteSync(cfg Config) (*VoteSync, error) { return nil, err } iotexAPI := iotexapi.NewAPIServiceClient(conn) - cli := iotex.NewAuthedClient(iotexAPI, operatorAccount) + apiClient := NewIoTeXClient(iotexAPI) + fetcher := &VoteFetcher{iotexAPI: iotexAPI} + authClient := iotex.NewAuthedClient(iotexAPI, operatorAccount) - vitaABI, err := abi.JSON(strings.NewReader(contract.VitaABI)) - if err != nil { - return nil, err - } vitaContractAddress, err := address.FromString(cfg.VitaContractAddress) if err != nil { return nil, err } - vitaContract := cli.Contract(vitaContractAddress, vitaABI) - - d, err := vitaContract.Read("vps").Call(ctx) - if err != nil { - return nil, err - } - ret, err := d.Unmarshal() - if err != nil { - return nil, err - } - addr, err := util.ToEtherAddress(ret[0]) - if err != nil { - return nil, err - } - vpsContractAddress, err := address.FromBytes(addr.Bytes()) + vitaContract, err := NewVitaContract(authClient, vitaContractAddress) if err != nil { return nil, err } - d, err = vitaContract.Read("donationPoolAddress").Call(ctx) - if err != nil { - return nil, err - } - ret, err = d.Unmarshal() - if err != nil { - return nil, err - } - addr, err = util.ToEtherAddress(ret[0]) - if err != nil { - return nil, err - } - brokerContractAddress, err := address.FromBytes(addr.Bytes()) + vpsContractAddress, err := vitaContract.VPS() if err != nil { return nil, err } - d, err = vitaContract.Read("rewardPoolAddress").Call(ctx) + brokerContractAddress, err := vitaContract.DonationPoolAddress() if err != nil { return nil, err } - ret, err = d.Unmarshal() - if err != nil { - return nil, err - } - addr, err = util.ToEtherAddress(ret[0]) - if err != nil { - return nil, err - } - clerkContractAddress, err := address.FromBytes(addr.Bytes()) + + clerkContractAddress, err := vitaContract.RewardPoolAddress() if err != nil { return nil, err } zap.L().Info("vote contracts.", zap.String("brokerContract", brokerContractAddress.String()), zap.String("clerkContract", clerkContractAddress.String())) - vpsABI, err := abi.JSON(strings.NewReader(contract.RotatableVPSABI)) + vpsContract, err := NewRotatableWeightedVPS(authClient, vpsContractAddress, cfg.PaginationSize) if err != nil { return nil, err } - vpsContract := cli.Contract(vpsContractAddress, vpsABI) - d, err = vpsContract.Read("viewID").Call(ctx) - if err != nil { - return nil, err - } - ret, err = d.Unmarshal() - if err != nil { - return nil, err - } - lastUpdateHeight, err := util.ToBigInt(ret[0]) + lastUpdateHeight, err := vpsContract.ViewID() if err != nil { return nil, err } @@ -227,20 +167,12 @@ func NewVoteSync(cfg Config) (*VoteSync, error) { if lastUpdateHeight.Uint64() > _viewIDOffsite { lastUpdateHeight.Sub(lastUpdateHeight, new(big.Int).SetUint64(_viewIDOffsite)) } - lastUpdateTimestamp, err := iotexBlockTime(context.Background(), iotexAPI, lastUpdateHeight.Uint64()) + lastUpdateTimestamp, err := apiClient.BlockTime(lastUpdateHeight.Uint64()) if err != nil { return nil, err } - d, err = vpsContract.Read("inactiveViewID").Call(ctx) - if err != nil { - return nil, err - } - ret, err = d.Unmarshal() - if err != nil { - return nil, err - } - lastViewHeight, err := util.ToBigInt(ret[0]) + lastViewHeight, err := vpsContract.InactiveViewID() if err != nil { return nil, err } @@ -250,20 +182,12 @@ func NewVoteSync(cfg Config) (*VoteSync, error) { if lastViewHeight.Uint64() < cfg.FairBankHeight { lastViewHeight = new(big.Int).SetUint64(cfg.FairBankHeight) } - lastViewTimestamp, err := iotexBlockTime(context.Background(), iotexAPI, lastViewHeight.Uint64()) + lastViewTimestamp, err := apiClient.BlockTime(lastViewHeight.Uint64()) if err != nil { return nil, err } - d, err = vitaContract.Read("lastDonationPoolClaimViewID").Call(ctx) - if err != nil { - return nil, err - } - ret, err = d.Unmarshal() - if err != nil { - return nil, err - } - lastBrokerUpdateHeight, err := util.ToBigInt(ret[0]) + lastBrokerUpdateHeight, err := vitaContract.LastDonationPoolClaimViewID() if err != nil { return nil, err } @@ -271,15 +195,7 @@ func NewVoteSync(cfg Config) (*VoteSync, error) { lastBrokerUpdateHeight.Sub(lastBrokerUpdateHeight, new(big.Int).SetUint64(_viewIDOffsite)) } - d, err = vitaContract.Read("lastRewardPoolClaimViewID").Call(ctx) - if err != nil { - return nil, err - } - ret, err = d.Unmarshal() - if err != nil { - return nil, err - } - lastClerkUpdateHeight, err := util.ToBigInt(ret[0]) + lastClerkUpdateHeight, err := vitaContract.LastRewardPoolClaimViewID() if err != nil { return nil, err } @@ -287,27 +203,37 @@ func NewVoteSync(cfg Config) (*VoteSync, error) { lastClerkUpdateHeight.Sub(lastClerkUpdateHeight, new(big.Int).SetUint64(_viewIDOffsite)) } - brokerABI, err := abi.JSON(strings.NewReader(contract.BrokerABI)) + brokerContract, err := NewBrokerContract(authClient, brokerContractAddress, cfg.BrokerPaginationSize) if err != nil { return nil, err } - brokerContract := cli.Contract(brokerContractAddress, brokerABI) - clerkABI, err := abi.JSON(strings.NewReader(contract.ClerkABI)) + clerkContract, err := NewClerkContract(authClient, clerkContractAddress) if err != nil { return nil, err } - clerkContract := cli.Contract(clerkContractAddress, clerkABI) + + var agentContract *agentContract + if cfg.EnableAgentMode { + agentContractAddress, err := address.FromString(cfg.AgentContractAddress) + if err != nil { + return nil, err + } + agentContract, err = NewAgentContract(authClient, agentContractAddress) + if err != nil { + return nil, err + } + } return &VoteSync{ + client: apiClient, + agentContract: agentContract, + votingPowers: &VotingPowers{}, + fetcher: fetcher, vpsContract: vpsContract, brokerContract: brokerContract, clerkContract: clerkContract, - service: cli, - iotexAPI: iotexAPI, timeInternal: cfg.GravityChainTimeInterval, - paginationSize: cfg.PaginationSize, - brokerPaginationSize: cfg.BrokerPaginationSize, lastViewHeight: lastViewHeight.Uint64(), lastViewTimestamp: lastViewTimestamp, lastUpdateHeight: lastUpdateHeight.Uint64(), @@ -316,16 +242,18 @@ func NewVoteSync(cfg Config) (*VoteSync, error) { lastClerkUpdateHeight: lastClerkUpdateHeight.Uint64(), terminate: make(chan bool), terminated: false, - discordBotToken: cfg.DiscordBotToken, - discordChannelID: cfg.DiscordChannelID, - discordMsg: cfg.DiscordMsg, - discordReminder: cfg.DiscordReminder, - dardanellesHeight: cfg.DardaenllesHeight, - fairbankHeight: cfg.FairBankHeight, + discord: &discord{ + botToken: cfg.DiscordBotToken, + channelID: cfg.DiscordChannelID, + newCycleMsg: cfg.DiscordMsg, + reminderMsg: cfg.DiscordReminder, + }, + dardanellesHeight: cfg.DardanellesHeight, + fairbankHeight: cfg.FairBankHeight, }, nil } -//Start starts voteSync +// Start starts voteSync func (vc *VoteSync) Start(ctx context.Context) { errChan := make(chan error) @@ -343,12 +271,12 @@ func (vc *VoteSync) Start(ctx context.Context) { case <-vc.terminate: return case <-ticker.C: - tip, err := iotexTip(ctx, vc.iotexAPI) + tip, err := vc.client.Tip() if err != nil { zap.L().Error("failed to get iotex tip", zap.Error(err)) continue } - blockTime, err := iotexBlockTime(ctx, vc.iotexAPI, tip) + blockTime, err := vc.client.BlockTime(tip) if err != nil { zap.L().Error("failed to get block time", zap.Error(err)) continue @@ -358,16 +286,14 @@ func (vc *VoteSync) Start(ctx context.Context) { zap.L().Error("failed to sync votes", zap.Error(err)) continue } - if err := vc.sendDiscordMsg(vc.discordMsg); err != nil { + if err := vc.discord.SendNewCycleMessage(); err != nil { zap.L().Error("failed to send discord msg", zap.Error(err)) } - vc.discordReminded = false } - if blockTime.After(vc.lastUpdateTimestamp.Add(vc.timeInternal*24/25)) && !vc.discordReminded { - if err := vc.sendDiscordMsg(vc.discordReminder); err != nil { + if blockTime.After(vc.lastUpdateTimestamp.Add(vc.timeInternal*24/25)) && !vc.discord.Reminded() { + if err := vc.discord.SendReminder(); err != nil { zap.L().Error("failed to send discord reminder", zap.Error(err)) } - vc.discordReminded = true } if vc.lastUpdateHeight > vc.lastBrokerUpdateHeight { @@ -388,48 +314,45 @@ func (vc *VoteSync) Start(ctx context.Context) { }() } -//Stop stops voteSync +// Stop stops voteSync func (vc *VoteSync) Stop(ctx context.Context) { if vc.terminated { return } close(vc.terminate) vc.terminated = true - return -} - -func (vc *VoteSync) brokerReset() error { - caller := vc.brokerContract.Execute("reset").SetGasPrice(big.NewInt(int64(1 * unit.Qev))).SetGasLimit(5000000) - return wait.Wait(context.Background(), caller) } -func (vc *VoteSync) brokerNextBidToSettle() (uint64, error) { - d, err := vc.brokerContract.Read("nextBidToSettle").Call(context.Background()) - if err != nil { - return 0, err +func (vc *VoteSync) ProofForAccount(acct address.Address) ([]byte, error) { + if vc.agentContract == nil { + return nil, errors.New("agent mode is not enabled") } - ret, err := d.Unmarshal() + agentCycle, size, claimed, err := vc.agentContract.Claimed(acct) if err != nil { - return 0, err + return nil, err } - nextBidToSettle, err := util.ToBigInt(ret[0]) - if err != nil { - return 0, err + if claimed { + return nil, nil + } + cycle, power := vc.votingPowers.VotingPower(common.BytesToAddress(acct.Bytes())) + if cycle.Cmp(agentCycle) != 0 { + return nil, errors.New("unexpected status") } - return nextBidToSettle.Uint64(), nil + + return vc.agentContract.Digest( + new(big.Int).Div(power.Mul(power, size), vc.votingPowers.Total()), + cycle, + ) } func (vc *VoteSync) brokerSettle() error { oldStart := uint64(0) for { - caller := vc.brokerContract.Execute( - "settle", big.NewInt(0).SetUint64(uint64(vc.brokerPaginationSize))). - SetGasPrice(big.NewInt(int64(1 * unit.Qev))).SetGasLimit(5000000) - if err := wait.Wait(context.Background(), caller); err != nil { + if err := vc.brokerContract.Settle(); err != nil { return err } - newStart, err := vc.brokerNextBidToSettle() + newStart, err := vc.brokerContract.NextBidToSettle() if err != nil { return err } @@ -448,7 +371,7 @@ func (vc *VoteSync) settle(h uint64) error { return errors.Wrap(err, "broker settle error") } l.Info("Finished broker settle.") - if err := vc.brokerReset(); err != nil { + if err := vc.brokerContract.Reset(); err != nil { return errors.Wrap(err, "broker reset error") } vc.lastBrokerUpdateHeight = h @@ -458,8 +381,7 @@ func (vc *VoteSync) settle(h uint64) error { func (vc *VoteSync) claimForClerk() error { zap.L().Info("Start clerk claim process.", zap.Uint64("lastClerkUpdateHeight", vc.lastClerkUpdateHeight)) - caller := vc.clerkContract.Execute("claim").SetGasPrice(big.NewInt(int64(1 * unit.Qev))).SetGasLimit(5000000) - if err := wait.Wait(context.Background(), caller); err != nil { + if err := vc.clerkContract.Claim(); err != nil { return err } vc.lastClerkUpdateHeight = vc.lastUpdateHeight @@ -467,56 +389,71 @@ func (vc *VoteSync) claimForClerk() error { return nil } -func (vc *VoteSync) updateVotingPowers(addrs []common.Address, weights []*big.Int) error { - caller := vc.vpsContract.Execute("updateVotingPowers", addrs, weights). - SetGasPrice(big.NewInt(int64(1 * unit.Qev))).SetGasLimit(7000000) - return wait.Wait(context.Background(), caller) -} - func (vc *VoteSync) sync(ctx context.Context, prevHeight, currHeight uint64, currTs time.Time) error { zap.L().Info("Start VoteSyncing.", zap.Uint64("lastViewID", prevHeight), zap.Uint64("nextViewID", currHeight)) - ret, err := vc.fetchVotesUpdate(ctx, prevHeight, currHeight) - if err != nil { - return errors.Wrap(err, "fetch vote error") - } - zap.L().Info("Need to sync.", zap.Int("numVoter", len(ret))) - - var ( - addrs []common.Address - weights []*big.Int - reqNum int - ) - if len(ret) == 0 { // just to pause the contract when nothing cahnged - if err := vc.updateVotingPowers(addrs, weights); err != nil { - return errors.Wrap(err, fmt.Sprintf("update vote error, reqNum:%d", reqNum)) + if vc.agentContract != nil { + buckets, candidates, err := vc.fetcher.FetchBucketsByHeight(ctx, currHeight) + if err != nil { + return err } - } - for _, vote := range ret { - addr, err := ioToEthAddress(vote.Voter) + totalVotes := big.NewInt(0) + votingPowers := make(map[common.Address]*big.Int) + votes := calWeightedVotes(buckets, candidates) + for _, vote := range votes { + totalVotes = totalVotes.Add(totalVotes, vote.Votes) + addr, err := ioToEthAddress(vote.Voter) + if err != nil { + return err + } + votingPowers[addr] = vote.Votes + } + totalPower, err := vc.vpsContract.TotalPower() if err != nil { - return errors.Wrap(err, fmt.Sprintf("failed convert address:%s", vote.Voter)) + return err + } + if totalPower.Cmp(_fixedAdhocPower) != 0 { + votes, err := vc.vpsContract.VoterPowers() + if err != nil { + return err + } + voters := make([]common.Address, 0, len(votes)+1) + weights := make([]*big.Int, 0, len(votes)+1) + for voter := range votes { + voters = append(voters, voter) + weights = append(weights, big.NewInt(0)) + } + voters = append(voters, vc.agentContract.Address()) + weights = append(weights, _fixedAdhocPower) + if err := vc.vpsContract.UpdateVotingPowers(voters, weights); err != nil { + return err + } } - addrs = append(addrs, addr) - weights = append(weights, vote.Votes) + vc.votingPowers.Update(nil, totalVotes, votingPowers) + } else { + ret, err := vc.fetchVotesUpdate(ctx, prevHeight, currHeight) + if err != nil { + return errors.Wrap(err, "fetch vote error") + } + zap.L().Info("Need to sync.", zap.Int("numVoter", len(ret))) - if len(addrs)%int(vc.paginationSize/4) == 0 { - if err := vc.updateVotingPowers(addrs, weights); err != nil { - return errors.Wrap(err, fmt.Sprintf("update vote error, reqNum:%d", reqNum)) + var ( + addrs []common.Address + weights []*big.Int + ) + for _, vote := range ret { + addr, err := ioToEthAddress(vote.Voter) + if err != nil { + return errors.Wrap(err, fmt.Sprintf("failed convert address:%s", vote.Voter)) } - reqNum++ - addrs = []common.Address{} - weights = []*big.Int{} + addrs = append(addrs, addr) + weights = append(weights, vote.Votes) } - } - if len(addrs) > 0 { - if err := vc.updateVotingPowers(addrs, weights); err != nil { - return errors.Wrap(err, fmt.Sprintf("update vote error, reqNum:%d", reqNum)) + if err := vc.vpsContract.UpdateVotingPowers(addrs, weights); err != nil { + return errors.Wrap(err, "update vote error") } } - caller := vc.vpsContract.Execute("rotate", new(big.Int).SetUint64(currHeight+_viewIDOffsite)). - SetGasPrice(big.NewInt(int64(1 * unit.Qev))).SetGasLimit(4000000) - if err := wait.Wait(context.Background(), caller); err != nil { + if err := vc.vpsContract.Rotate(new(big.Int).SetUint64(currHeight + _viewIDOffsite)); err != nil { return errors.Wrap(err, "failed to execute rotate") } @@ -532,11 +469,10 @@ func (vc *VoteSync) sync(ctx context.Context, prevHeight, currHeight uint64, cur func (vc *VoteSync) fetchVotesUpdate(ctx context.Context, prevHeight, currHeight uint64) ([]*WeightedVote, error) { // prevHeight == 0, only run at first 2 time. get all votes from currHeight if prevHeight == 0 { - currB, currC, err := vc.retryFetchBucketsByHeight(ctx, currHeight) + currB, currC, err := vc.fetcher.FetchBucketsByHeight(ctx, currHeight) if err != nil { return nil, err } - n := calWeightedVotes(currB, currC) var ret []*WeightedVote for _, nv := range n { @@ -545,12 +481,12 @@ func (vc *VoteSync) fetchVotesUpdate(ctx context.Context, prevHeight, currHeight return ret, nil } - prevB, prevC, err := vc.retryFetchBucketsByHeight(ctx, prevHeight) + prevB, prevC, err := vc.fetcher.FetchBucketsByHeight(ctx, prevHeight) if err != nil { return nil, err } - currB, currC, err := vc.retryFetchBucketsByHeight(ctx, currHeight) + currB, currC, err := vc.fetcher.FetchBucketsByHeight(ctx, currHeight) if err != nil { return nil, err } @@ -561,7 +497,7 @@ func (vc *VoteSync) fetchVotesUpdate(ctx context.Context, prevHeight, currHeight var ret []*WeightedVote // check for all voters in old view // if they don't exist in new view map, append 0 value for them - // if they do exisit in new view map, append only if the vote value is different + // if they do exist in new view map, append only if the vote value is different for k, pv := range p { nv, ok := n[k] if !ok { @@ -585,83 +521,6 @@ func (vc *VoteSync) fetchVotesUpdate(ctx context.Context, prevHeight, currHeight return ret, nil } -func (vc *VoteSync) retryFetchBucketsByHeight(ctx context.Context, h uint64) (*iotextypes.VoteBucketList, *iotextypes.CandidateListV2, error) { - var ( - ret1 *iotextypes.VoteBucketList - ret2 *iotextypes.CandidateListV2 - err error - ) - nerr := backoff.Retry(func() error { - ret1, err = getAllStakingBuckets(ctx, vc.iotexAPI, h) - if err != nil { - return err - } - ret2, err = getAllStakingCandidates(ctx, vc.iotexAPI, h) - return err - }, backoff.NewExponentialBackOff()) - if nerr != nil { - zap.L().Error( - "failed to fetch vote result by height", - zap.Error(nerr), - zap.Uint64("height", h), - ) - } - return ret1, ret2, nerr -} - -func iotexTip(ctx context.Context, iotexAPI iotexapi.APIServiceClient) (uint64, error) { - response, err := iotexAPI.GetChainMeta( - context.Background(), - &iotexapi.GetChainMetaRequest{}, - ) - if err != nil { - return 0, err - } - - return response.ChainMeta.Height, nil -} - -func iotexBlockTime(ctx context.Context, iotexAPI iotexapi.APIServiceClient, h uint64) (time.Time, error) { - resp, err := iotexAPI.GetBlockMetas(ctx, &iotexapi.GetBlockMetasRequest{ - Lookup: &iotexapi.GetBlockMetasRequest_ByIndex{ - ByIndex: &iotexapi.GetBlockMetasByIndexRequest{ - Start: h, Count: 1, - }, - }, - }) - if err != nil { - return time.Now(), errors.Wrapf(err, "failed to fetch block meta %v", h) - } - bms := resp.GetBlkMetas() - if len(bms) != 1 { - return time.Now(), errors.Wrapf(err, "asked 1 block, but got none-1 value %v", h) - } - ts := bms[0].GetTimestamp() - bt, err := ptypes.Timestamp(ts) - if err != nil { - return time.Now(), errors.Wrapf(err, "failed to parse timestamp in blockmeta %v", h) - } - return bt, nil -} - -func (vc *VoteSync) sendDiscordMsg(msg string) error { - if vc.discordBotToken == "" || msg == "" { - return nil - } - - dg, err := discordgo.New("Bot " + vc.discordBotToken) - if err != nil { - return err - } - if err := dg.Open(); err != nil { - return err - } - defer dg.Close() - - _, err = dg.ChannelMessageSend(vc.discordChannelID, msg) - return err -} - func calWeightedVotes(bs *iotextypes.VoteBucketList, cs *iotextypes.CandidateListV2) map[string]*WeightedVote { n := make(map[string]*WeightedVote) for _, v := range bs.GetBuckets() { @@ -710,113 +569,3 @@ func calculateVoteWeight(v *iotextypes.VoteBucket, selfStake bool) *big.Int { weightedAmount, _ := amount.Mul(amount, big.NewFloat(weight)).Int(nil) return weightedAmount } - -func getAllStakingBuckets(ctx context.Context, chainClient iotexapi.APIServiceClient, height uint64) (voteBucketListAll *iotextypes.VoteBucketList, err error) { - voteBucketListAll = &iotextypes.VoteBucketList{} - for i := uint32(0); ; i++ { - offset := i * readBucketsLimit - size := uint32(readBucketsLimit) - voteBucketList, err := getStakingBuckets(ctx, chainClient, offset, size, height) - if err != nil { - return nil, errors.Wrap(err, "failed to get bucket") - } - voteBucketListAll.Buckets = append(voteBucketListAll.Buckets, voteBucketList.Buckets...) - if len(voteBucketList.Buckets) < readBucketsLimit { - break - } - } - return -} - -// getStakingBuckets get specific buckets by height -func getStakingBuckets(ctx context.Context, chainClient iotexapi.APIServiceClient, offset, limit uint32, height uint64) (voteBucketList *iotextypes.VoteBucketList, err error) { - methodName, err := proto.Marshal(&iotexapi.ReadStakingDataMethod{ - Method: iotexapi.ReadStakingDataMethod_BUCKETS, - }) - if err != nil { - return nil, err - } - arg, err := proto.Marshal(&iotexapi.ReadStakingDataRequest{ - Request: &iotexapi.ReadStakingDataRequest_Buckets{ - Buckets: &iotexapi.ReadStakingDataRequest_VoteBuckets{ - Pagination: &iotexapi.PaginationParam{ - Offset: offset, - Limit: limit, - }, - }, - }, - }) - if err != nil { - return nil, err - } - readStateRequest := &iotexapi.ReadStateRequest{ - ProtocolID: []byte(protocolID), - MethodName: methodName, - Arguments: [][]byte{arg}, - Height: strconv.FormatUint(height, 10), - } - readStateRes, err := chainClient.ReadState(ctx, readStateRequest) - if err != nil { - return - } - voteBucketList = &iotextypes.VoteBucketList{} - if err := proto.Unmarshal(readStateRes.GetData(), voteBucketList); err != nil { - return nil, errors.Wrap(err, "failed to unmarshal VoteBucketList") - } - return -} - -func getAllStakingCandidates(ctx context.Context, chainClient iotexapi.APIServiceClient, height uint64) (candidateListAll *iotextypes.CandidateListV2, err error) { - candidateListAll = &iotextypes.CandidateListV2{} - for i := uint32(0); ; i++ { - offset := i * readCandidatesLimit - size := uint32(readCandidatesLimit) - candidateList, err := getStakingCandidates(ctx, chainClient, offset, size, height) - if err != nil { - return nil, errors.Wrap(err, "failed to get candidates") - } - candidateListAll.Candidates = append(candidateListAll.Candidates, candidateList.Candidates...) - if len(candidateList.Candidates) < readCandidatesLimit { - break - } - } - return -} - -// getStakingCandidates get specific candidates by height -func getStakingCandidates(ctx context.Context, chainClient iotexapi.APIServiceClient, offset, limit uint32, height uint64) (candidateList *iotextypes.CandidateListV2, err error) { - methodName, err := proto.Marshal(&iotexapi.ReadStakingDataMethod{ - Method: iotexapi.ReadStakingDataMethod_CANDIDATES, - }) - if err != nil { - return nil, err - } - arg, err := proto.Marshal(&iotexapi.ReadStakingDataRequest{ - Request: &iotexapi.ReadStakingDataRequest_Candidates_{ - Candidates: &iotexapi.ReadStakingDataRequest_Candidates{ - Pagination: &iotexapi.PaginationParam{ - Offset: offset, - Limit: limit, - }, - }, - }, - }) - if err != nil { - return nil, err - } - readStateRequest := &iotexapi.ReadStateRequest{ - ProtocolID: []byte(protocolID), - MethodName: methodName, - Arguments: [][]byte{arg}, - Height: strconv.FormatUint(height, 10), - } - readStateRes, err := chainClient.ReadState(ctx, readStateRequest) - if err != nil { - return - } - candidateList = &iotextypes.CandidateListV2{} - if err := proto.Unmarshal(readStateRes.GetData(), candidateList); err != nil { - return nil, errors.Wrap(err, "failed to unmarshal VoteBucketList") - } - return -} diff --git a/votesync/votesync_test.go b/votesync/votesync_test.go index 4261709..4058952 100644 --- a/votesync/votesync_test.go +++ b/votesync/votesync_test.go @@ -25,7 +25,7 @@ func TestFetchVotesByHeight(t *testing.T) { require := require.New(t) vs, err := NewVoteSync(cfg) require.NoError(err) - re1, re2, err := vs.retryFetchBucketsByHeight(context.Background(), 3459523) + re1, re2, err := vs.fetcher.FetchBucketsByHeight(context.Background(), 3459523) require.NoError(err) // TODO: this is due to incomplete staking index db, fix later require.Zero(len(re1.GetBuckets())) diff --git a/votesync/votingpowerstats.go b/votesync/votingpowerstats.go new file mode 100644 index 0000000..ee5f884 --- /dev/null +++ b/votesync/votingpowerstats.go @@ -0,0 +1,35 @@ +package votesync + +import ( + "math/big" + "sync" + + "github.com/ethereum/go-ethereum/common" +) + +type VotingPowers struct { + lock sync.RWMutex + cycle *big.Int + totalVotes *big.Int + votingPowers map[common.Address]*big.Int +} + +func (vp *VotingPowers) Total() *big.Int { + return vp.totalVotes +} + +func (vp *VotingPowers) VotingPower(acct common.Address) (*big.Int, *big.Int) { + vp.lock.RLock() + defer vp.lock.RUnlock() + + return vp.cycle, vp.votingPowers[acct] +} + +func (vp *VotingPowers) Update(cycle *big.Int, total *big.Int, votingPowers map[common.Address]*big.Int) { + vp.lock.Lock() + defer vp.lock.Unlock() + + vp.cycle = cycle + vp.totalVotes = total + vp.votingPowers = votingPowers +}