Stringer interface for AddressDescriptor
This commit is contained in:
parent
1109cd7878
commit
fdf1fe612f
@ -2,6 +2,7 @@ package bchain
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@ -114,6 +115,10 @@ func (e *RPCError) Error() string {
|
||||
// AddressDescriptor is an opaque type obtained by parser.GetAddrDesc* methods
|
||||
type AddressDescriptor []byte
|
||||
|
||||
func (ad AddressDescriptor) String() string {
|
||||
return "ad:" + hex.EncodeToString(ad)
|
||||
}
|
||||
|
||||
// BlockChain defines common interface to block chain daemon
|
||||
type BlockChain interface {
|
||||
// life-cycle methods
|
||||
|
||||
@ -339,11 +339,10 @@ type blockTxs struct {
|
||||
|
||||
func (d *RocksDB) resetValueSatToZero(valueSat *big.Int, addrDesc bchain.AddressDescriptor, logText string) {
|
||||
ad, _, err := d.chainParser.GetAddressesFromAddrDesc(addrDesc)
|
||||
had := hex.EncodeToString(addrDesc)
|
||||
if err != nil {
|
||||
glog.Warningf("rocksdb: unparsable address hex '%v' reached negative %s %v, resetting to 0. Parser error %v", had, logText, valueSat.String(), err)
|
||||
glog.Warningf("rocksdb: unparsable address hex '%v' reached negative %s %v, resetting to 0. Parser error %v", addrDesc, logText, valueSat.String(), err)
|
||||
} else {
|
||||
glog.Warningf("rocksdb: address %v hex '%v' reached negative %s %v, resetting to 0", ad, had, logText, valueSat.String())
|
||||
glog.Warningf("rocksdb: address %v hex '%v' reached negative %s %v, resetting to 0", ad, addrDesc, logText, valueSat.String())
|
||||
}
|
||||
valueSat.SetInt64(0)
|
||||
}
|
||||
@ -1073,8 +1072,7 @@ func (d *RocksDB) disconnectTxAddresses(wb *gorocksdb.WriteBatch, height uint32,
|
||||
b.BalanceSat.Add(&b.BalanceSat, &t.ValueSat)
|
||||
} else {
|
||||
ad, _, _ := d.chainParser.GetAddressesFromAddrDesc(t.AddrDesc)
|
||||
had := hex.EncodeToString(t.AddrDesc)
|
||||
glog.Warningf("Balance for address %s (%s) not found", ad, had)
|
||||
glog.Warningf("Balance for address %s (%s) not found", ad, t.AddrDesc)
|
||||
}
|
||||
s = string(inputs[i].btxID)
|
||||
sa, exist := txAddressesToUpdate[s]
|
||||
@ -1110,8 +1108,7 @@ func (d *RocksDB) disconnectTxAddresses(wb *gorocksdb.WriteBatch, height uint32,
|
||||
}
|
||||
} else {
|
||||
ad, _, _ := d.chainParser.GetAddressesFromAddrDesc(t.AddrDesc)
|
||||
had := hex.EncodeToString(t.AddrDesc)
|
||||
glog.Warningf("Balance for address %s (%s) not found", ad, had)
|
||||
glog.Warningf("Balance for address %s (%s) not found", ad, t.AddrDesc)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user