@@ -491,8 +491,8 @@ func (eh *contractStakingEventHandler) handleBucketTypeDeactivatedEvent(event ev
491491 return err
492492 }
493493
494- id , bt , ok := eh .dirty .matchBucketType (amountParam , durationParam .Uint64 ())
495- if ! ok {
494+ id , bt := eh .dirty .matchBucketType (amountParam , durationParam .Uint64 ())
495+ if bt == nil {
496496 return errors .Wrapf (errBucketTypeNotExist , "amount %d, duration %d" , amountParam .Int64 (), durationParam .Uint64 ())
497497 }
498498 bt .ActivatedAt = maxBlockNumber
@@ -519,8 +519,8 @@ func (eh *contractStakingEventHandler) handleStakedEvent(event eventParam, heigh
519519 return err
520520 }
521521
522- btIdx , _ , ok := eh .dirty .matchBucketType (amountParam , durationParam .Uint64 ())
523- if ! ok {
522+ btIdx , bt := eh .dirty .matchBucketType (amountParam , durationParam .Uint64 ())
523+ if bt == nil {
524524 return errors .Wrapf (errBucketTypeNotExist , "amount %d, duration %d" , amountParam .Int64 (), durationParam .Uint64 ())
525525 }
526526 owner , ok := eh .tokenOwner [tokenIDParam .Uint64 ()]
@@ -557,8 +557,8 @@ func (eh *contractStakingEventHandler) handleLockedEvent(event eventParam) error
557557 if ! ok {
558558 return errors .Wrapf (errBucketTypeNotExist , "id %d" , b .TypeIndex )
559559 }
560- newBtIdx , _ , ok := eh .dirty .matchBucketType (bt .Amount , durationParam .Uint64 ())
561- if ! ok {
560+ newBtIdx , newBt := eh .dirty .matchBucketType (bt .Amount , durationParam .Uint64 ())
561+ if newBt == nil {
562562 return errors .Wrapf (errBucketTypeNotExist , "amount %v, duration %d" , bt .Amount , durationParam .Uint64 ())
563563 }
564564 b .TypeIndex = newBtIdx
@@ -615,8 +615,8 @@ func (eh *contractStakingEventHandler) handleMergedEvent(event eventParam) error
615615 }
616616
617617 // merge to the first bucket
618- btIdx , _ , ok := eh .dirty .matchBucketType (amountParam , durationParam .Uint64 ())
619- if ! ok {
618+ btIdx , bt := eh .dirty .matchBucketType (amountParam , durationParam .Uint64 ())
619+ if bt == nil {
620620 return errors .Wrapf (errBucketTypeNotExist , "amount %d, duration %d" , amountParam .Int64 (), durationParam .Uint64 ())
621621 }
622622 b , ok := eh .dirty .getBucketInfo (tokenIDsParam [0 ].Uint64 ())
@@ -651,8 +651,8 @@ func (eh *contractStakingEventHandler) handleBucketExpandedEvent(event eventPara
651651 if ! ok {
652652 return errors .Wrapf (ErrBucketNotExist , "token id %d" , tokenIDParam .Uint64 ())
653653 }
654- newBtIdx , _ , ok := eh .dirty .matchBucketType (amountParam , durationParam .Uint64 ())
655- if ! ok {
654+ newBtIdx , newBucketType := eh .dirty .matchBucketType (amountParam , durationParam .Uint64 ())
655+ if newBucketType == nil {
656656 return errors .Wrapf (errBucketTypeNotExist , "amount %d, duration %d" , amountParam .Int64 (), durationParam .Uint64 ())
657657 }
658658 b .TypeIndex = newBtIdx
0 commit comments