Skip to content

Commit

Permalink
Fix: memory usage decrease
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Mar 6, 2022
1 parent aad148d commit 576c2e8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions cmd/indexer/indexer/boost.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type BoostIndexer struct {
receiver *Receiver
state block.Block
currentProtocol protocol.Protocol
blocks map[int64]Block
blocks map[int64]*Block

updateTicker *time.Ticker
Network types.Network
Expand Down Expand Up @@ -71,7 +71,7 @@ func NewBoostIndexer(ctx context.Context, internalCtx config.Context, rpcConfig
Network: network,
rpc: rpc,
receiver: NewReceiver(rpc, 100, int64(receiverThreadsCount)),
blocks: make(map[int64]Block),
blocks: make(map[int64]*Block),
}

if err := bi.init(ctx, bi.Context.StorageDB); err != nil {
Expand Down Expand Up @@ -232,7 +232,7 @@ func (bi *BoostIndexer) Index(ctx context.Context, head noderpc.Header) error {
return nil
}

func (bi *BoostIndexer) handleBlock(ctx context.Context, block Block) error {
func (bi *BoostIndexer) handleBlock(ctx context.Context, block *Block) error {
result := parsers.NewResult()
err := bi.StorageDB.DB.RunInTransaction(ctx,
func(tx *pg.Tx) error {
Expand Down Expand Up @@ -364,7 +364,7 @@ func (bi *BoostIndexer) createBlock(head noderpc.Header, tx pg.DBI) error {
return nil
}

func (bi *BoostIndexer) getDataFromBlock(block Block) (*parsers.Result, error) {
func (bi *BoostIndexer) getDataFromBlock(block *Block) (*parsers.Result, error) {
result := parsers.NewResult()
if block.Header.Level <= 1 {
return result, nil
Expand Down
8 changes: 4 additions & 4 deletions cmd/indexer/indexer/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Receiver struct {
rpc noderpc.INode
queue chan int64
failed chan int64
blocks chan Block
blocks chan *Block

threads chan struct{}
present map[int64]struct{}
Expand All @@ -36,7 +36,7 @@ func NewReceiver(rpc noderpc.INode, queueSize, threadsCount int64) *Receiver {
rpc: rpc,
queue: make(chan int64, queueSize),
failed: make(chan int64, queueSize),
blocks: make(chan Block, queueSize),
blocks: make(chan *Block, queueSize),
threads: make(chan struct{}, threadsCount),
present: make(map[int64]struct{}),
}
Expand All @@ -59,7 +59,7 @@ func (r *Receiver) Start(ctx context.Context) {
}

// Blocks -
func (r *Receiver) Blocks() <-chan Block {
func (r *Receiver) Blocks() <-chan *Block {
return r.blocks
}

Expand Down Expand Up @@ -111,7 +111,7 @@ func (r *Receiver) job(level int64) {
r.failed <- level
return
}
r.blocks <- block
r.blocks <- &block

r.mx.Lock()
delete(r.present, level)
Expand Down

0 comments on commit 576c2e8

Please sign in to comment.