Skip to content

Commit

Permalink
Merge pull request #6113 from filecoin-project/fix/elvindu/fix-event-…
Browse files Browse the repository at this point in the history
…subscription

set gcConfidence = 2 * constants.ForkLengthThreshold /  设置gcConfidence的值为2 * constants.ForkLengthThreshold
  • Loading branch information
simlecode authored Aug 22, 2023
2 parents 712e6d8 + 5252965 commit 9acf862
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
3 changes: 1 addition & 2 deletions app/submodule/eth/eth_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ type ethAPI struct {
}

func (a *ethAPI) start(ctx context.Context) error {
const ChainHeadConfidence = 1
ev, err := events.NewEventsWithConfidence(ctx, a.chain, ChainHeadConfidence)
ev, err := events.NewEvents(ctx, a.chain)
if err != nil {
return err
}
Expand Down
4 changes: 1 addition & 3 deletions app/submodule/eth/eth_event_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ import (
"github.com/zyedidia/generic/queue"
)

const ChainHeadConfidence = 1

var _ v1.IETHEvent = (*ethEventAPI)(nil)

func newEthEventAPI(ctx context.Context, em *EthSubModule) (*ethEventAPI, error) {
Expand Down Expand Up @@ -128,7 +126,7 @@ func (e *ethEventAPI) Start(ctx context.Context) error {
// Start garbage collection for filters
go e.GC(ctx, time.Duration(e.em.cfg.FevmConfig.Event.FilterTTL))

ev, err := events.NewEventsWithConfidence(ctx, e.ChainAPI, ChainHeadConfidence)
ev, err := events.NewEvents(ctx, e.ChainAPI)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Events struct {
*hcEvents
}

func NewEventsWithConfidence(ctx context.Context, api IEvent, gcConfidence abi.ChainEpoch) (*Events, error) {
func newEventsWithConfidence(ctx context.Context, api IEvent, gcConfidence abi.ChainEpoch) (*Events, error) {
cache := newCache(api, gcConfidence)

ob := newObserver(cache, gcConfidence)
Expand All @@ -40,5 +40,5 @@ func NewEventsWithConfidence(ctx context.Context, api IEvent, gcConfidence abi.C

func NewEvents(ctx context.Context, api IEvent) (*Events, error) {
gcConfidence := 2 * constants.ForkLengthThreshold
return NewEventsWithConfidence(ctx, api, gcConfidence)
return newEventsWithConfidence(ctx, api, gcConfidence)
}

0 comments on commit 9acf862

Please sign in to comment.