Skip to content

Commit

Permalink
Change lastBlockProcessed to uint64 in memstore instead of map
Browse files Browse the repository at this point in the history
  • Loading branch information
bitwiseguy committed Aug 23, 2023
1 parent 0a35258 commit ca4f034
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions node/engine/store/memstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type MemStore struct {
consensusChannels safesync.Map[[]byte]
channelToObjective safesync.Map[protocols.ObjectiveId]
vouchers safesync.Map[[]byte]
blocks safesync.Map[uint64]
lastBlockProcessed uint64

key string // the signing key of the store's engine
address string // the (Ethereum) address associated to the signing key
Expand All @@ -40,7 +40,7 @@ func NewMemStore(key []byte) Store {
ms.consensusChannels = safesync.Map[[]byte]{}
ms.channelToObjective = safesync.Map[protocols.ObjectiveId]{}
ms.vouchers = safesync.Map[[]byte]{}
ms.blocks = safesync.Map[uint64]{}
ms.lastBlockProcessed = 0
return &ms
}

Expand Down Expand Up @@ -129,18 +129,13 @@ func (ms *MemStore) SetObjective(obj protocols.Objective) error {

// SetLastBlockProcessed
func (ms *MemStore) SetLastBlockProcessed(blockNumber uint64) error {
ms.blocks.Store(lastBlockProcessedKey, blockNumber)
ms.lastBlockProcessed = blockNumber
return nil
}

// GetLastBlockProcessed
func (ms *MemStore) GetLastBlockProcessed() (uint64, error) {
blockNumber, ok := ms.blocks.Load(lastBlockProcessedKey)
if !ok {
return 0, fmt.Errorf("could not retrieve lastBlockSeen from memstore")
}

return blockNumber, nil
return ms.lastBlockProcessed, nil
}

// SetChannel sets the channel in the store.
Expand Down

0 comments on commit ca4f034

Please sign in to comment.