From d6de3c332024e3bce253b861ef12ef0dec676ba1 Mon Sep 17 00:00:00 2001 From: ssd04 Date: Wed, 7 Aug 2024 16:33:27 +0300 Subject: [PATCH] fixes after review --- process/dataPool.go | 12 +++++++++++- process/publisherHandler.go | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/process/dataPool.go b/process/dataPool.go index 57dd4a8..c61c703 100644 --- a/process/dataPool.go +++ b/process/dataPool.go @@ -239,9 +239,19 @@ func (bp *dataPool) getCheckpointData(checkpointKey string) (*data.BlockCheckpoi return checkpoint, nil } +func deepCopyMap(originalMap map[uint32]uint64) map[uint32]uint64 { + newMap := make(map[uint32]uint64) + + for key, value := range originalMap { + newMap[key] = value + } + + return newMap +} + func (bp *dataPool) saveLastSoftCheckpoint() error { bp.mutMap.RLock() - softCheckpointMap := bp.softCheckpointMap + softCheckpointMap := deepCopyMap(bp.softCheckpointMap) bp.mutMap.RUnlock() softCheckpoint := &data.BlockCheckpoint{} diff --git a/process/publisherHandler.go b/process/publisherHandler.go index 9a74d5d..d5fe0b6 100644 --- a/process/publisherHandler.go +++ b/process/publisherHandler.go @@ -156,7 +156,7 @@ func (ph *publisherHandler) updatePublishCheckpoint() { func (ph *publisherHandler) handleLastCheckpointOnInit() error { if ph.resetCheckpoints { - log.Debug("did not checked last publisher checkpoint on init") + log.Debug("did not check last publisher checkpoint on init") return nil }