Skip to content

Commit

Permalink
fix: update chain tip info
Browse files Browse the repository at this point in the history
This also removes some unnecessary locking around chainsync clients
which was causing problems.
  • Loading branch information
agaffney committed May 28, 2024
1 parent 9e1e282 commit 9e17465
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions chainsync/chainsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,6 @@ func (s *State) RemoveClientConnId(connId ouroboros.ConnectionId) {
}

func (s *State) sub(key ouroboros.ConnectionId) chan ChainsyncBlock {
s.Lock()
defer s.Unlock()
tmpChan := make(chan ChainsyncBlock, maxRecentBlocks)
if s.subs == nil {
s.subs = make(map[ouroboros.ConnectionId]chan ChainsyncBlock)
Expand All @@ -176,8 +174,6 @@ func (s *State) sub(key ouroboros.ConnectionId) chan ChainsyncBlock {
}

func (s *State) unsub(key ouroboros.ConnectionId) {
s.Lock()
defer s.Unlock()
if _, ok := s.subs[key]; ok {
close(s.subs[key])
delete(s.subs, key)
Expand All @@ -194,6 +190,8 @@ func (s *State) AddBlock(block ChainsyncBlock) {
)
blockNum_int.Set(float64(block.Point.BlockNumber))
slotNum_int.Set(float64(block.Point.SlotNumber))
// Update tip
s.tip = block.Point
// Prune older blocks
if len(s.recentBlocks) > maxRecentBlocks {
s.recentBlocks = s.recentBlocks[len(s.recentBlocks)-maxRecentBlocks:]
Expand Down

0 comments on commit 9e17465

Please sign in to comment.