hook head change coalescer to mpool

This commit is contained in:
vyzo 2020-11-04 17:53:00 +02:00
parent 08aab1c48a
commit 84c9d1dbb7

View File

@ -2,6 +2,7 @@ package messagepool
import (
"context"
"time"
"github.com/ipfs/go-cid"
pubsub "github.com/libp2p/go-libp2p-pubsub"
@ -9,9 +10,12 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/lotus/chain/stmgr"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types"
)
var HeadChangeCoalesceDelay = time.Second
type Provider interface {
SubscribeHeadChanges(func(rev, app []*types.TipSet) error) *types.TipSet
PutMessage(m types.ChainMsg) (cid.Cid, error)
@ -34,7 +38,7 @@ func NewProvider(sm *stmgr.StateManager, ps *pubsub.PubSub) Provider {
}
func (mpp *mpoolProvider) SubscribeHeadChanges(cb func(rev, app []*types.TipSet) error) *types.TipSet {
mpp.sm.ChainStore().SubscribeHeadChanges(cb)
mpp.sm.ChainStore().SubscribeHeadChanges(store.WrapHeadChangeCoalescer(cb, HeadChangeCoalesceDelay))
return mpp.sm.ChainStore().GetHeaviestTipSet()
}