Clear all request internal cache when node is stopped
This commit is contained in:
parent
f47187b00b
commit
ccce8b9a80
|
@ -22,11 +22,11 @@ type requestMeta struct {
|
|||
|
||||
// NewRequestsRegistry creates instance of the RequestsRegistry and returns pointer to it.
|
||||
func NewRequestsRegistry(delay time.Duration) *RequestsRegistry {
|
||||
return &RequestsRegistry{
|
||||
delay: delay,
|
||||
uidToTopics: map[common.Hash]common.Hash{},
|
||||
byTopicsHash: map[common.Hash]requestMeta{},
|
||||
r := &RequestsRegistry{
|
||||
delay: delay,
|
||||
}
|
||||
r.Clear()
|
||||
return r
|
||||
}
|
||||
|
||||
// RequestsRegistry keeps map for all requests with timestamp when they were made.
|
||||
|
@ -73,6 +73,14 @@ func (r *RequestsRegistry) Unregister(uid common.Hash) {
|
|||
}
|
||||
}
|
||||
|
||||
// Clear recreates all structures used for caching requests.
|
||||
func (r *RequestsRegistry) Clear() {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
r.uidToTopics = map[common.Hash]common.Hash{}
|
||||
r.byTopicsHash = map[common.Hash]requestMeta{}
|
||||
}
|
||||
|
||||
// topicsToHash returns non-cryptographic hash of the topics.
|
||||
func topicsToHash(topics []whisper.TopicType) common.Hash {
|
||||
hash := fnv.New32()
|
||||
|
|
|
@ -302,6 +302,7 @@ func (s *Service) Stop() error {
|
|||
if s.config.EnableLastUsedMonitor {
|
||||
s.lastUsedMonitor.Stop()
|
||||
}
|
||||
s.requestsRegistry.Clear()
|
||||
s.envelopesMonitor.Stop()
|
||||
s.mailMonitor.Stop()
|
||||
return nil
|
||||
|
|
Loading…
Reference in New Issue