-
Notifications
You must be signed in to change notification settings - Fork 0
/
scanpooltx.go
38 lines (34 loc) · 917 Bytes
/
scanpooltx.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package colx
import (
"fmt"
"time"
"github.com/weijun-sh/gethscan-server/log"
"github.com/weijun-sh/gethscan-server/tokens/tools"
)
var (
scannedTxs = tools.NewCachedScannedTxs(3000)
)
// StartPoolTransactionScanJob scan job
func (b *Bridge) StartPoolTransactionScanJob() {
chainName := b.ChainConfig.BlockChain
log.Infof("[scanpool] start scan %v tx pool job", chainName)
errorSubject := fmt.Sprintf("[scanpool] get %v pool txs error", chainName)
scanSubject := fmt.Sprintf("[scanpool] scanned %v tx", chainName)
for {
txids, err := b.GetPoolTxidList()
if err != nil {
log.Error(errorSubject, "err", err)
time.Sleep(retryIntervalInScanJob)
continue
}
for _, txid := range txids {
if scannedTxs.IsTxScanned(txid) {
continue
}
log.Trace(scanSubject, "txid", txid)
b.processTransaction(txid)
scannedTxs.CacheScannedTx(txid)
}
time.Sleep(restIntervalInScanJob)
}
}