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