Separate addrindex tx fetch error messages
* Decouple logging and handling of distinct error messages for cases of failed tx look up. * This also fixes a bug wherein the `addrindexer` failed to lookup a tx (since it didn't exist), but continued since the returned error was nil.
This commit is contained in:
parent
3318a24a88
commit
4cee2a48cc
1 changed files with 10 additions and 5 deletions
|
@ -6,6 +6,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"container/heap"
|
"container/heap"
|
||||||
|
"fmt"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
@ -239,7 +240,7 @@ func (a *addrIndexer) indexManager() {
|
||||||
addrIndex, err := a.indexBlockAddrs(indexJob.blk)
|
addrIndex, err := a.indexBlockAddrs(indexJob.blk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
adxrLog.Errorf("Unable to index transactions of"+
|
adxrLog.Errorf("Unable to index transactions of"+
|
||||||
" block %v", err)
|
" block: %v", err)
|
||||||
a.server.Stop()
|
a.server.Stop()
|
||||||
goto fin
|
goto fin
|
||||||
}
|
}
|
||||||
|
@ -400,7 +401,7 @@ out:
|
||||||
addrIndex, err := a.indexBlockAddrs(indexJob.blk)
|
addrIndex, err := a.indexBlockAddrs(indexJob.blk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
adxrLog.Errorf("Unable to index transactions of"+
|
adxrLog.Errorf("Unable to index transactions of"+
|
||||||
" block %v", err)
|
" block: %v", err)
|
||||||
a.server.Stop()
|
a.server.Stop()
|
||||||
break out
|
break out
|
||||||
}
|
}
|
||||||
|
@ -467,9 +468,13 @@ func (a *addrIndexer) indexBlockAddrs(blk *btcutil.Block) (database.BlockAddrInd
|
||||||
// Lookup and fetch the referenced output's tx.
|
// Lookup and fetch the referenced output's tx.
|
||||||
prevOut := txIn.PreviousOutPoint
|
prevOut := txIn.PreviousOutPoint
|
||||||
txList, err := a.server.db.FetchTxBySha(&prevOut.Hash)
|
txList, err := a.server.db.FetchTxBySha(&prevOut.Hash)
|
||||||
if err != nil || len(txList) == 0 {
|
if len(txList) == 0 {
|
||||||
adxrLog.Errorf("Couldn't get referenced "+
|
return nil, fmt.Errorf("transaction %v not found",
|
||||||
"txOut (%v): %v", prevOut, err)
|
prevOut.Hash)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
adxrLog.Errorf("Error fetching tx %v: %v",
|
||||||
|
prevOut.Hash, err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
prevOutTx := txList[len(txList)-1]
|
prevOutTx := txList[len(txList)-1]
|
||||||
|
|
Loading…
Reference in a new issue