Skip to content
This repository has been archived by the owner on Jul 18, 2020. It is now read-only.

Commit

Permalink
Changed elastic storage to commit only every 10th chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
vsubhuman committed Oct 17, 2019
1 parent 5aced68 commit 8822180
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/entities/elastic-storage/elastic-storage-processor.js
Expand Up @@ -97,6 +97,8 @@ class ElasticStorageProcessor implements StorageProcessor {

elasticConfig: ElasticConfigType

lastChunk: number;

constructor(
logger: Logger,
elasticConfig: ElasticConfigType,
Expand Down Expand Up @@ -194,6 +196,7 @@ class ElasticStorageProcessor implements StorageProcessor {
async onLaunch() {
await this.ensureElasticTemplates()
await this.removeUnsealed()
this.lastChunk = await this.getLatestStableChunk()
this.logger.debug('Launched ElasticStorageProcessor storage processor.')
}

Expand All @@ -216,7 +219,7 @@ class ElasticStorageProcessor implements StorageProcessor {
async storeGenesisUtxos(utxos: Array<UtxoType>) {
// TODO: check bulk upload response
this.logger.debug('storeGenesisUtxos: store utxos to "txio" index and create fake txs in "tx" index')
const chunk = 1
const chunk = ++this.lastChunk;

const utxosObjs = utxos.map((utxo) => new UtxoData(utxo))
const txioBody = formatBulkUploadBody(utxosObjs, {
Expand Down Expand Up @@ -285,7 +288,7 @@ class ElasticStorageProcessor implements StorageProcessor {
const utxosToStore = []
const txInputsIds = []
const blockTxs = []
const chunk = (await this.getLatestStableChunk()) + 1
const chunk = ++this.lastChunk;
for (const block of blocks) {
const txs = block.getTxs()
if (txs.length > 0) {
Expand Down

0 comments on commit 8822180

Please sign in to comment.