Commit c5c479b2 authored by duanjinfei's avatar duanjinfei

add print log

parent 751ac5c3
...@@ -85,9 +85,8 @@ func (p *PullEvent) GetLogs() { ...@@ -85,9 +85,8 @@ func (p *PullEvent) GetLogs() {
query.Addresses = p.contractList query.Addresses = p.contractList
for { for {
query.FromBlock = p.lastBlock query.FromBlock = p.lastBlock
log.Info("start fileter start at ", p.lastBlock.Text(10))
height, err := p.client.BlockNumber(p.ctx) height, err := p.client.BlockNumber(p.ctx)
log.Info("current node height:", height) log.Info("Current node height:", height)
if height < p.lastBlock.Uint64() { if height < p.lastBlock.Uint64() {
time.Sleep(time.Second) time.Sleep(time.Second)
continue continue
...@@ -101,13 +100,16 @@ func (p *PullEvent) GetLogs() { ...@@ -101,13 +100,16 @@ func (p *PullEvent) GetLogs() {
query.FromBlock = new(big.Int).Sub(p.lastBlock, big.NewInt(backBlock)) query.FromBlock = new(big.Int).Sub(p.lastBlock, big.NewInt(backBlock))
query.ToBlock = p.lastBlock query.ToBlock = p.lastBlock
} }
log.Infof("start filter bloct at:%s, end filter block at:%s", query.FromBlock.Text(10), query.ToBlock.Text(10))
allLogs, err := p.client.FilterLogs(p.ctx, query) allLogs, err := p.client.FilterLogs(p.ctx, query)
if err != nil { if err != nil {
log.Error("filter logs failed", err) log.Error("filter logs failed", err)
continue continue
} }
log.Info("Filter log length:", len(allLogs))
if len(allLogs) > 0 { if len(allLogs) > 0 {
for _, vlog := range allLogs { for _, vlog := range allLogs {
log.Info("Logs to be processed:", vlog)
handle, exist := p.contractHandler[vlog.Address] handle, exist := p.contractHandler[vlog.Address]
if exist { if exist {
handle(vlog) handle(vlog)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment