diff --git a/monitor/gnfd_block_processor.go b/monitor/gnfd_block_processor.go index 01858ba..91c33af 100644 --- a/monitor/gnfd_block_processor.go +++ b/monitor/gnfd_block_processor.go @@ -137,9 +137,8 @@ func (p *GnfdBlockProcessor) Process(blockHeight uint64) error { util.Logger.Errorf("processor: %s, fail to handle EventDeleteObject err: %s", p.Name(), err) return err } - if rawSql != "" { - rawDeleteSqls = append(rawDeleteSqls, rawSqls...) - } + rawDeleteSqls = append(rawDeleteSqls, rawSqls...) + } } @@ -336,10 +335,14 @@ func (p *GnfdBlockProcessor) handleEventDeleteObject(blockHeight uint64, event a objectId := deleteObject.ObjectId.Uint64() item, err := p.itemDao.GetByObjectId(context.Background(), int64(objectId), true) - if err != nil && err != gorm.ErrRecordNotFound { + if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { return sqls, err } + if err != nil && errors.Is(err, gorm.ErrRecordNotFound) { + return sqls, nil + } + rawSql1 := fmt.Sprintf("delete from item_stats where item_id = %d ", item.Id) sqls = append(sqls, rawSql1)