From 335848c1cd8efffd781005bdaf5a1ca028864219 Mon Sep 17 00:00:00 2001 From: tamirms Date: Thu, 16 Mar 2023 10:21:04 +0000 Subject: [PATCH] Remove mutex from change compactor (#4811) --- ingest/change_compactor.go | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/ingest/change_compactor.go b/ingest/change_compactor.go index 6a82966131..cee0b2591b 100644 --- a/ingest/change_compactor.go +++ b/ingest/change_compactor.go @@ -2,7 +2,6 @@ package ingest import ( "encoding/base64" - "sync" "github.com/stellar/go/support/errors" "github.com/stellar/go/xdr" @@ -50,7 +49,6 @@ import ( type ChangeCompactor struct { // ledger key => Change cache map[string]Change - mutex sync.Mutex encodingBuffer *xdr.EncodingBuffer } @@ -70,9 +68,6 @@ func NewChangeCompactor() *ChangeCompactor { // cache takes too much memory, you apply changes returned by GetChanges and // create a new ChangeCompactor object to continue ingestion. func (c *ChangeCompactor) AddChange(change Change) error { - c.mutex.Lock() - defer c.mutex.Unlock() - switch { case change.Pre == nil && change.Post != nil: return c.addCreatedChange(change) @@ -215,9 +210,6 @@ func (c *ChangeCompactor) addRemovedChange(change Change) error { // GetChanges returns a slice of Changes in the cache. The order of changes is // random but each change is connected to a separate entry. func (c *ChangeCompactor) GetChanges() []Change { - c.mutex.Lock() - defer c.mutex.Unlock() - changes := make([]Change, 0, len(c.cache)) for _, entryChange := range c.cache { @@ -229,7 +221,5 @@ func (c *ChangeCompactor) GetChanges() []Change { // Size returns number of ledger entries in the cache. func (c *ChangeCompactor) Size() int { - c.mutex.Lock() - defer c.mutex.Unlock() return len(c.cache) }