Skip to content
Snippets Groups Projects
Commit 9863e814 authored by Miguel Montes's avatar Miguel Montes
Browse files

Corrección de bug en la obtención de coinbase en nodos sin cuentas.

parent fa1aafc4
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,6 @@ package bfa ...@@ -2,7 +2,6 @@ package bfa
import ( import (
. "../util" . "../util"
"fmt"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus/clique" "github.com/ethereum/go-ethereum/consensus/clique"
"github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/p2p"
...@@ -55,6 +54,10 @@ func (node *Node) Call(result interface{}, method string, args ...interface{}) { ...@@ -55,6 +54,10 @@ func (node *Node) Call(result interface{}, method string, args ...interface{}) {
Check((*rpc.Client)(node).Call(result, method, args...)) 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 { func (node *Node) BlockNumber() int64 {
var bn rpc.BlockNumber var bn rpc.BlockNumber
node.Call(&bn, "eth_blockNumber") node.Call(&bn, "eth_blockNumber")
...@@ -87,22 +90,8 @@ func (node *Node) Balance(account common.Address) *big.Int { ...@@ -87,22 +90,8 @@ func (node *Node) Balance(account common.Address) *big.Int {
return node.BalanceAtBlock(account, -1) return node.BalanceAtBlock(account, -1)
} }
func (node *Node) Coinbase() (coinbase string, err error) { func (node *Node) Coinbase() (address string, err error) {
defer func() { err = node.CallWithError(&address, "eth_coinbase")
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[:])
return return
} }
...@@ -190,7 +179,9 @@ func (node *Node) SealersAtBlock(blockNumber int64) (signers []string) { ...@@ -190,7 +179,9 @@ func (node *Node) SealersAtBlock(blockNumber int64) (signers []string) {
func (node *Node) IsSealer(address string) bool { func (node *Node) IsSealer(address string) bool {
if address == Self { if address == Self {
var err error var (
err error
)
if address, err = node.Coinbase(); err != nil { if address, err = node.Coinbase(); err != nil {
return false return false
} }
...@@ -200,7 +191,9 @@ func (node *Node) IsSealer(address string) bool { ...@@ -200,7 +191,9 @@ func (node *Node) IsSealer(address string) bool {
func (node *Node) IsSealerAtBlock(address string, blockNumber int64) bool { func (node *Node) IsSealerAtBlock(address string, blockNumber int64) bool {
if address == Self { if address == Self {
var err error var (
err error
)
if address, err = node.Coinbase(); err != nil { if address, err = node.Coinbase(); err != nil {
return false return false
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment