From 9863e8140433b53f3b8bd571d7f06bffc575adc3 Mon Sep 17 00:00:00 2001 From: Miguel Montes <miguel.montes@gmail.com> Date: Wed, 12 Dec 2018 16:17:16 -0300 Subject: [PATCH] =?UTF-8?q?Correcci=C3=B3n=20de=20bug=20en=20la=20obtenci?= =?UTF-8?q?=C3=B3n=20de=20coinbase=20en=20nodos=20sin=20cuentas.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bfa_client/src/bfa/node.go | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/bfa_client/src/bfa/node.go b/bfa_client/src/bfa/node.go index 09882ed..f85b2fc 100644 --- a/bfa_client/src/bfa/node.go +++ b/bfa_client/src/bfa/node.go @@ -2,7 +2,6 @@ package bfa import ( . "../util" - "fmt" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/consensus/clique" "github.com/ethereum/go-ethereum/p2p" @@ -55,6 +54,10 @@ func (node *Node) Call(result interface{}, method string, args ...interface{}) { Check((*rpc.Client)(node).Call(result, method, args...)) } +func (node *Node) CallWithError(result interface{}, method string, args ...interface{}) error { + return (*rpc.Client)(node).Call(result, method, args...) +} + func (node *Node) BlockNumber() int64 { var bn rpc.BlockNumber node.Call(&bn, "eth_blockNumber") @@ -87,22 +90,8 @@ func (node *Node) Balance(account common.Address) *big.Int { return node.BalanceAtBlock(account, -1) } -func (node *Node) Coinbase() (coinbase string, err error) { - defer func() { - if e := recover(); e != nil { - switch s := e.(type) { - case string: - err = fmt.Errorf(s) - case error: - err = s - default: - err = fmt.Errorf("unknown error while getting coinbase: %v", e) - } - } - }() - var address common.Address - node.Call(&address, "eth_coinbase") - coinbase = BytesToHex(address[:]) +func (node *Node) Coinbase() (address string, err error) { + err = node.CallWithError(&address, "eth_coinbase") return } @@ -190,7 +179,9 @@ func (node *Node) SealersAtBlock(blockNumber int64) (signers []string) { func (node *Node) IsSealer(address string) bool { if address == Self { - var err error + var ( + err error + ) if address, err = node.Coinbase(); err != nil { return false } @@ -200,7 +191,9 @@ func (node *Node) IsSealer(address string) bool { func (node *Node) IsSealerAtBlock(address string, blockNumber int64) bool { if address == Self { - var err error + var ( + err error + ) if address, err = node.Coinbase(); err != nil { return false } -- GitLab