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

Declarado tipo bfa.Address

parent 35327557
No related branches found
No related tags found
No related merge requests found
......@@ -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...))
}
......
......@@ -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)
}
......
......@@ -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)
......
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