chain events: Separate heightEvents from main struct
This commit is contained in:
parent
519eed9290
commit
50960b3f8c
@ -28,21 +28,12 @@ type eventChainStore interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Events struct {
|
type Events struct {
|
||||||
cs eventChainStore
|
cs eventChainStore
|
||||||
gcConfidence uint64
|
|
||||||
|
|
||||||
tsc *tipSetCache
|
tsc *tipSetCache
|
||||||
lk sync.Mutex
|
lk sync.Mutex
|
||||||
|
|
||||||
ctr triggerId
|
heightEvents
|
||||||
|
|
||||||
// ChainAt
|
|
||||||
|
|
||||||
heightTriggers map[triggerId]*heightHandler
|
|
||||||
|
|
||||||
htTriggerHeights map[triggerH][]triggerId
|
|
||||||
htHeights map[msgH][]triggerId
|
|
||||||
|
|
||||||
calledEvents
|
calledEvents
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,18 +43,23 @@ func NewEvents(cs eventChainStore) *Events {
|
|||||||
tsc := newTSCache(gcConfidence)
|
tsc := newTSCache(gcConfidence)
|
||||||
|
|
||||||
e := &Events{
|
e := &Events{
|
||||||
cs: cs,
|
cs: cs,
|
||||||
gcConfidence: uint64(gcConfidence),
|
|
||||||
|
|
||||||
tsc: tsc,
|
tsc: tsc,
|
||||||
|
|
||||||
heightTriggers: map[uint64]*heightHandler{},
|
heightEvents: heightEvents{
|
||||||
htTriggerHeights: map[uint64][]uint64{},
|
tsc: tsc,
|
||||||
htHeights: map[uint64][]uint64{},
|
gcConfidence: uint64(gcConfidence),
|
||||||
|
|
||||||
|
heightTriggers: map[uint64]*heightHandler{},
|
||||||
|
htTriggerHeights: map[uint64][]uint64{},
|
||||||
|
htHeights: map[uint64][]uint64{},
|
||||||
|
},
|
||||||
|
|
||||||
calledEvents: calledEvents{
|
calledEvents: calledEvents{
|
||||||
cs: cs,
|
cs: cs,
|
||||||
tsc: tsc,
|
tsc: tsc,
|
||||||
|
gcConfidence: uint64(gcConfidence),
|
||||||
|
|
||||||
confQueue: map[triggerH]map[msgH][]*queuedEvent{},
|
confQueue: map[triggerH]map[msgH][]*queuedEvent{},
|
||||||
revertQueue: map[msgH][]triggerH{},
|
revertQueue: map[msgH][]triggerH{},
|
||||||
|
@ -50,8 +50,9 @@ type queuedEvent struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type calledEvents struct {
|
type calledEvents struct {
|
||||||
cs eventChainStore
|
cs eventChainStore
|
||||||
tsc *tipSetCache
|
tsc *tipSetCache
|
||||||
|
gcConfidence uint64
|
||||||
|
|
||||||
lk sync.Mutex
|
lk sync.Mutex
|
||||||
|
|
||||||
|
@ -2,9 +2,26 @@ package store
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/filecoin-project/go-lotus/chain/types"
|
"github.com/filecoin-project/go-lotus/chain/types"
|
||||||
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (e *Events) headChangeAt(rev, app []*types.TipSet) error {
|
type heightEvents struct {
|
||||||
|
lk sync.Mutex
|
||||||
|
tsc *tipSetCache
|
||||||
|
gcConfidence uint64
|
||||||
|
|
||||||
|
ctr triggerId
|
||||||
|
|
||||||
|
heightTriggers map[triggerId]*heightHandler
|
||||||
|
|
||||||
|
htTriggerHeights map[triggerH][]triggerId
|
||||||
|
htHeights map[msgH][]triggerId
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *heightEvents) headChangeAt(rev, app []*types.TipSet) error {
|
||||||
|
e.lk.Lock()
|
||||||
|
defer e.lk.Unlock()
|
||||||
|
|
||||||
// highest tipset is always the first (see cs.ReorgOps)
|
// highest tipset is always the first (see cs.ReorgOps)
|
||||||
newH := app[0].Height()
|
newH := app[0].Height()
|
||||||
|
|
||||||
@ -55,7 +72,7 @@ func (e *Events) headChangeAt(rev, app []*types.TipSet) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Events) ChainAt(hnd HeightHandler, rev RevertHandler, confidence int, h uint64) error {
|
func (e *heightEvents) ChainAt(hnd HeightHandler, rev RevertHandler, confidence int, h uint64) error {
|
||||||
e.lk.Lock()
|
e.lk.Lock()
|
||||||
defer e.lk.Unlock()
|
defer e.lk.Unlock()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user