Skip to content

Commit

Permalink
added cache id on ShouldNotifyEviction
Browse files Browse the repository at this point in the history
  • Loading branch information
sstanculeanu committed Oct 6, 2023
1 parent 0c48618 commit b476f34
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions testscommon/evictionNotifierStub.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package testscommon
// EvictionNotifierStub -
type EvictionNotifierStub struct {
NotifyEvictionCalled func(txHash []byte, cacheId string)
ShouldNotifyEvictionCalled func(txHash []byte) bool
ShouldNotifyEvictionCalled func(txHash []byte, cacheId string) bool
}

// NotifyEviction -
Expand All @@ -14,9 +14,9 @@ func (stub *EvictionNotifierStub) NotifyEviction(txHash []byte, cacheId string)
}

// ShouldNotifyEviction -
func (stub *EvictionNotifierStub) ShouldNotifyEviction(txHash []byte) bool {
func (stub *EvictionNotifierStub) ShouldNotifyEviction(txHash []byte, cacheId string) bool {
if stub.ShouldNotifyEvictionCalled != nil {
return stub.ShouldNotifyEvictionCalled(txHash)
return stub.ShouldNotifyEvictionCalled(txHash, cacheId)
}
return false
}
Expand Down
2 changes: 1 addition & 1 deletion txcache/baseTxCache.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (cache *baseTxCache) enqueueEvictedHashesForNotification(txHashes [][]byte)

for _, handler := range handlers {
for _, txHash := range txHashes {
if !handler.ShouldNotifyEviction(txHash) {
if !handler.ShouldNotifyEviction(txHash, cache.name) {
continue
}

Expand Down
2 changes: 1 addition & 1 deletion txcache/crossTxCache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestCrossTxCache_RegisterEvictionHandler(t *testing.T) {
require.True(t, bytes.Equal([]byte("hash-1"), hash))
ch <- struct{}{}
},
ShouldNotifyEvictionCalled: func(txHash []byte) bool {
ShouldNotifyEvictionCalled: func(txHash []byte, cacheId string) bool {
return true
},
})
Expand Down
4 changes: 2 additions & 2 deletions txcache/txCache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ func TestTxCache_NoCriticalInconsistency_WhenConcurrentAdditionsAndRemovals(t *t
atomic.AddUint32(&handlerCalls, 1)
evictionHandlerWG.Done()
},
ShouldNotifyEvictionCalled: func(txHash []byte) bool {
ShouldNotifyEvictionCalled: func(txHash []byte, cacheId string) bool {
return true
},
})
Expand Down Expand Up @@ -671,7 +671,7 @@ func TestTxCache_RegisterEvictionHandler(t *testing.T) {
require.True(t, bytes.Equal([]byte("hash-1"), hash) || bytes.Equal([]byte("hash-2"), hash))
ch <- atomic.LoadUint32(&cnt)
},
ShouldNotifyEvictionCalled: func(txHash []byte) bool {
ShouldNotifyEvictionCalled: func(txHash []byte, cacheId string) bool {
return true
},
})
Expand Down
2 changes: 1 addition & 1 deletion types/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,6 @@ type PersisterCreator interface {
// EvictionNotifier defines the behaviour of a component which is able to handle an evicted transaction
type EvictionNotifier interface {
NotifyEviction(txHash []byte, cacheId string)
ShouldNotifyEviction(txHash []byte) bool
ShouldNotifyEviction(txHash []byte, cacheId string) bool
IsInterfaceNil() bool
}

0 comments on commit b476f34

Please sign in to comment.