mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-25 03:47:18 +00:00
cli: split searchBatchSize
usage in upload-bin
command
Split searchBatchSize into constant for searching and uploading. Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
This commit is contained in:
parent
9fd375d56d
commit
5dab154582
1 changed files with 9 additions and 5 deletions
|
@ -32,8 +32,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Number of objects to search in a batch for finding max block in container.
|
// Number of objects to upload in a batch. All batches of uploadBatchSize size
|
||||||
searchBatchSize = 10000
|
// except the most recent one are guaranteed to be completed and don't contain gaps.
|
||||||
|
uploadBatchSize = 10000
|
||||||
|
// Number of objects to search in a batch. If it is larger than uploadBatchSize,
|
||||||
|
// it may lead to many duplicate uploads.
|
||||||
|
searchBatchSize = uploadBatchSize
|
||||||
// Size of object ID.
|
// Size of object ID.
|
||||||
oidSize = sha256.Size
|
oidSize = sha256.Size
|
||||||
)
|
)
|
||||||
|
@ -235,7 +239,7 @@ func fetchLatestMissingBlockIndex(ctx context.Context, p *pool.Pool, containerID
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if emptyBatchFound || (batch == numBatches && i == len(results)-1) {
|
if emptyBatchFound || (batch == numBatches && i == len(results)-1) {
|
||||||
return results[i].startIndex, nil
|
return results[i].startIndex / uploadBatchSize * uploadBatchSize, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -248,9 +252,9 @@ func uploadBlocks(ctx *cli.Context, p *pool.Pool, rpc *rpcclient.Client, signer
|
||||||
fmt.Fprintf(ctx.App.Writer, "No new blocks to upload. Need to upload starting from %d, current height %d\n", oldestMissingBlockIndex, currentBlockHeight)
|
fmt.Fprintf(ctx.App.Writer, "No new blocks to upload. Need to upload starting from %d, current height %d\n", oldestMissingBlockIndex, currentBlockHeight)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
for batchStart := oldestMissingBlockIndex; batchStart <= int(currentBlockHeight); batchStart += searchBatchSize {
|
for batchStart := oldestMissingBlockIndex; batchStart <= int(currentBlockHeight); batchStart += uploadBatchSize {
|
||||||
var (
|
var (
|
||||||
batchEnd = min(batchStart+searchBatchSize, int(currentBlockHeight)+1)
|
batchEnd = min(batchStart+uploadBatchSize, int(currentBlockHeight)+1)
|
||||||
errCh = make(chan error)
|
errCh = make(chan error)
|
||||||
doneCh = make(chan struct{})
|
doneCh = make(chan struct{})
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
|
|
Loading…
Reference in a new issue