From 7954c0c7ed98be314ce023ebd7ecee0e926bf0c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Talpalaru?= Date: Sun, 31 Mar 2019 22:38:21 +0200 Subject: [PATCH] release the memory a bit sooner --- eth/p2p/blockchain_sync.nim | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/eth/p2p/blockchain_sync.nim b/eth/p2p/blockchain_sync.nim index 0f34d8c..706e761 100644 --- a/eth/p2p/blockchain_sync.nim +++ b/eth/p2p/blockchain_sync.nim @@ -55,8 +55,9 @@ proc availableWorkItem(ctx: SyncContext): int = else: discard - let eb = ctx.workQueue[i].endIndex - if eb > maxPendingBlock: maxPendingBlock = eb + let endBlock = ctx.workQueue[i].endIndex + if endBlock > maxPendingBlock: + maxPendingBlock = endBlock let nextRequestedBlock = maxPendingBlock + 1 if nextRequestedBlock >= ctx.endBlockNumber: @@ -79,8 +80,8 @@ proc persistWorkItem(ctx: SyncContext, wi: var WantedBlocks) = of ValidationResult.Error: wi.state = Initial # successful or not, we're done with these blocks - wi.headers.setLen(0) - wi.bodies.setLen(0) + wi.headers = @[] + wi.bodies = @[] proc persistPendingWorkItems(ctx: SyncContext) = var nextStartIndex = ctx.finalizedBlock + 1