diff --git a/bfa_client/src/bfa/node.go b/bfa_client/src/bfa/node.go index 8394639e6b052af5134cf78a51e24ec693510290..256d96db22ab8b450ea7e05082cae4b93de06d87 100644 --- a/bfa_client/src/bfa/node.go +++ b/bfa_client/src/bfa/node.go @@ -14,6 +14,8 @@ import ( type Node rpc.Client +type Address struct{ common.Address } + type Snapshot struct { Number uint64 `json:"number"` // Block number where the snapshot was created Hash common.Hash `json:"hash"` // Block hash where the snapshot was created @@ -52,6 +54,10 @@ const ( SealerRounds = 2 ) +func (address Address) MarshalText() ([]byte, error) { + return []byte(address.Hex()), nil +} + func (node *Node) Call(result interface{}, method string, args ...interface{}) { Check((*rpc.Client)(node).Call(result, method, args...)) } diff --git a/bfa_client/src/client/bfa_client.go b/bfa_client/src/client/bfa_client.go index 224a13ff29df7b315005a3431fc81191b4ef6a75..448d7882a1c09c71a466ff012295eb2c18c14cbc 100644 --- a/bfa_client/src/client/bfa_client.go +++ b/bfa_client/src/client/bfa_client.go @@ -504,10 +504,10 @@ func snapshot() { func transfers() { type Transfer struct { - From string `json:"from"` - To string `json:"to"` - Amount *big.Int `json:"amount"` - BlockNumber int64 `json:"blockNumber"` + From bfa.Address `json:"from"` + To bfa.Address `json:"to"` + Amount *big.Int `json:"amount"` + BlockNumber int64 `json:"blockNumber"` } var ( first, last, end int64 @@ -548,7 +548,7 @@ func transfers() { dst := transaction.To if len(set) == 0 || set[src] || set[dst] { if json { - txs = append(txs, Transfer{src.Hex(), dst.Hex(), (*big.Int)(transaction.Value), i}) + txs = append(txs, Transfer{bfa.Address{src}, bfa.Address{dst}, (*big.Int)(transaction.Value), i}) } else { fmt.Printf("%v -> %v: %v (%v)\n", src.Hex(), dst.Hex(), transaction.Value, transaction.BlockNumber) } diff --git a/bfa_client/src/util/util.go b/bfa_client/src/util/util.go index dfff2b691aca548cf2513f2e1cda7d059787923c..a8e367038daeb50c832d5c9c072d1c9e88bbf3c8 100644 --- a/bfa_client/src/util/util.go +++ b/bfa_client/src/util/util.go @@ -20,6 +20,24 @@ func Contains(slice []string, s string) bool { return false } +func ContainsAddress(slice []common.Address, address common.Address) bool { + for _, x := range slice { + if x == address { + return true + } + } + return false +} + +func LessThanAddress(a common.Address, b common.Address) bool { + for i, x := range a { + if x < b[i] { + return true + } + } + return false +} + func Error(format string, args ...interface{}) { _, _ = fmt.Fprintf(os.Stderr, format, args...) os.Exit(1)