From 67fbe6a96262449f355fb7dd31e0f7969790c164 Mon Sep 17 00:00:00 2001 From: aarshkshah1992 Date: Fri, 14 Jun 2024 16:53:38 +0400 Subject: [PATCH] fix naming --- chain/events/filter/index.go | 36 +++++++++++++++---------------- chain/events/filter/index_test.go | 8 +++---- node/impl/full/eth.go | 4 ++-- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/chain/events/filter/index.go b/chain/events/filter/index.go index 53bdd6f187c..4329297d175 100644 --- a/chain/events/filter/index.go +++ b/chain/events/filter/index.go @@ -131,18 +131,18 @@ type EventIndex struct { stmtRevertEventSeen *sql.Stmt stmtRestoreEventSeen *sql.Stmt - mu sync.Mutex - subIdCounter uint64 - subscribedTipsets map[uint64]*tipsetSub + mu sync.Mutex + subIdCounter uint64 + updateSubs map[uint64]*updateSub } -type tipsetSub struct { +type updateSub struct { ctx context.Context - ch chan *TipsetUpdate + ch chan *EventIndexUpdate cancel context.CancelFunc } -type TipsetUpdate struct { +type EventIndexUpdate struct { Height uint64 TipsetCid cid.Cid Reverted bool @@ -628,7 +628,7 @@ func NewEventIndex(ctx context.Context, path string, chainStore *store.ChainStor return nil, xerrors.Errorf("error preparing eventIndex database statements: %w", err) } - eventIndex.subscribedTipsets = make(map[uint64]*tipsetSub) + eventIndex.updateSubs = make(map[uint64]*updateSub) return &eventIndex, nil } @@ -640,11 +640,11 @@ func (ei *EventIndex) Close() error { return ei.db.Close() } -func (ei *EventIndex) SubscribeTipsetUpdates() (uint64, chan *TipsetUpdate) { +func (ei *EventIndex) SubscribeUpdates() (uint64, chan *EventIndexUpdate) { subCtx, subCancel := context.WithCancel(context.Background()) - ch := make(chan *TipsetUpdate) + ch := make(chan *EventIndexUpdate) - tSub := &tipsetSub{ + tSub := &updateSub{ ctx: subCtx, cancel: subCancel, ch: ch, @@ -653,20 +653,20 @@ func (ei *EventIndex) SubscribeTipsetUpdates() (uint64, chan *TipsetUpdate) { ei.mu.Lock() subId := ei.subIdCounter ei.subIdCounter++ - ei.subscribedTipsets[subId] = tSub + ei.updateSubs[subId] = tSub ei.mu.Unlock() return subId, tSub.ch } -func (ei *EventIndex) UnsubscribeTipsetUpdates(subId uint64) { +func (ei *EventIndex) UnsubscribeUpdates(subId uint64) { ei.mu.Lock() - tSub, ok := ei.subscribedTipsets[subId] + tSub, ok := ei.updateSubs[subId] if !ok { ei.mu.Unlock() return } - delete(ei.subscribedTipsets, subId) + delete(ei.updateSubs, subId) ei.mu.Unlock() // cancel the subscription @@ -726,13 +726,13 @@ func (ei *EventIndex) CollectEvents(ctx context.Context, te *TipSetEvents, rever } ei.mu.Lock() - tSubs := ei.subscribedTipsets + tSubs := ei.updateSubs ei.mu.Unlock() for _, tSub := range tSubs { tSub := tSub select { - case tSub.ch <- &TipsetUpdate{ + case tSub.ch <- &EventIndexUpdate{ Height: uint64(te.msgTs.Height()), TipsetCid: tsKeyCid, Reverted: true, @@ -886,13 +886,13 @@ func (ei *EventIndex) CollectEvents(ctx context.Context, te *TipSetEvents, rever } ei.mu.Lock() - tSubs := ei.subscribedTipsets + tSubs := ei.updateSubs ei.mu.Unlock() for _, tSub := range tSubs { tSub := tSub select { - case tSub.ch <- &TipsetUpdate{ + case tSub.ch <- &EventIndexUpdate{ Height: uint64(te.msgTs.Height()), TipsetCid: tsKeyCid, Reverted: false, diff --git a/chain/events/filter/index_test.go b/chain/events/filter/index_test.go index 29370b82274..10b1648b13f 100644 --- a/chain/events/filter/index_test.go +++ b/chain/events/filter/index_test.go @@ -77,8 +77,8 @@ func TestEventIndexPrefillFilter(t *testing.T) { ei, err := NewEventIndex(context.Background(), dbPath, nil) require.NoError(t, err, "create event index") - _, subCh := ei.SubscribeTipsetUpdates() - out := make(chan *TipsetUpdate, 1) + _, subCh := ei.SubscribeUpdates() + out := make(chan *EventIndexUpdate, 1) go func() { tu := <-subCh out <- tu @@ -435,8 +435,8 @@ func TestEventIndexPrefillFilterExcludeReverted(t *testing.T) { ei, err := NewEventIndex(context.Background(), dbPath, nil) require.NoError(t, err, "create event index") - tCh := make(chan *TipsetUpdate, 3) - _, subCh := ei.SubscribeTipsetUpdates() + tCh := make(chan *EventIndexUpdate, 3) + _, subCh := ei.SubscribeUpdates() go func() { cnt := 0 for tu := range subCh { diff --git a/node/impl/full/eth.go b/node/impl/full/eth.go index a33548acd5e..443f56d440c 100644 --- a/node/impl/full/eth.go +++ b/node/impl/full/eth.go @@ -1321,8 +1321,8 @@ func (e *EthEventHandler) waitForHeightProcessed(ctx context.Context, height abi return xerrors.New("height is in the future") } - subId, subCh := ei.SubscribeTipsetUpdates() - defer ei.UnsubscribeTipsetUpdates(subId) + subId, subCh := ei.SubscribeUpdates() + defer ei.UnsubscribeUpdates(subId) for { select {