Handle possible address descriptor mismatch in db column addresses

pull/380/head
Martin Boehm 2020-01-27 14:33:13 +01:00
parent 0751ed452c
commit 58f426207e
1 changed files with 8 additions and 1 deletions

View File

@ -373,6 +373,7 @@ func (d *RocksDB) GetTransactions(address string, lower uint32, higher uint32, f
// Transaction are passed to callback function in the order from newest block to the oldest
func (d *RocksDB) GetAddrDescTransactions(addrDesc bchain.AddressDescriptor, lower uint32, higher uint32, fn GetTransactionsCallback) (err error) {
txidUnpackedLen := d.chainParser.PackedTxidLen()
addrDescLen := len(addrDesc)
startKey := packAddressKey(addrDesc, higher)
stopKey := packAddressKey(addrDesc, lower)
indexes := make([]int32, 0, 16)
@ -380,10 +381,16 @@ func (d *RocksDB) GetAddrDescTransactions(addrDesc bchain.AddressDescriptor, low
defer it.Close()
for it.Seek(startKey); it.Valid(); it.Next() {
key := it.Key().Data()
val := it.Value().Data()
if bytes.Compare(key, stopKey) > 0 {
break
}
if len(key) != addrDescLen+packedHeightBytes {
if glog.V(2) {
glog.Warningf("rocksdb: addrDesc %s - mixed with %s", addrDesc, hex.EncodeToString(key))
}
continue
}
val := it.Value().Data()
if glog.V(2) {
glog.Infof("rocksdb: addresses %s: %s", hex.EncodeToString(key), hex.EncodeToString(val))
}