Skip to content

Commit

Permalink
Remove mutex from change compactor (#4811)
Browse files Browse the repository at this point in the history
  • Loading branch information
tamirms authored Mar 16, 2023
1 parent 8e78b57 commit 335848c
Showing 1 changed file with 0 additions and 10 deletions.
10 changes: 0 additions & 10 deletions ingest/change_compactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package ingest

import (
"encoding/base64"
"sync"

"github.com/stellar/go/support/errors"
"github.com/stellar/go/xdr"
Expand Down Expand Up @@ -50,7 +49,6 @@ import (
type ChangeCompactor struct {
// ledger key => Change
cache map[string]Change
mutex sync.Mutex
encodingBuffer *xdr.EncodingBuffer
}

Expand All @@ -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)
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
}

0 comments on commit 335848c

Please sign in to comment.