src/blockchain/normalizer.js
/**
   * Normalize the provided pledges in chunks of `batchSize`. If a particular batch fails, we will try again
   * reducing the batch sized in half, until we are only normalizing a single pledge. If a single pledge fails
   * to normalize, we will log the pledgeId and manual action will need to be taken.
   *
   * If a pledge fails to normalized 2x then the feathers cache is out of sync with what the blockchain knows
   * and there is most likely a bug elsewhere in the codebase.
   *
   * Note: we consider normalization a success as soon as we receive a txHash. This means there is a possibility
   * that the normalization can still fail, but the tx was valid when we sent it. These pledges will be re-normalized
   * the next time this is run.
   *
   * @param {Array} pledges the ids of the pledges to normalize
   * @param {int} batchSize (optional) the size of the batch to chunk the requests into. Defaults to 20.
   */
Normalize the provided pledges in chunks of `batchSize`. If a particular batch fails, we will try again
reducing the batch sized in half, until we are only normalizing a single pledge. If a single pledge fails
to normalize, we will log the pledgeId and manual action will need to be taken.

If a pledge fails to normalized 2x then the feathers cache is out of sync with what the blockchain knows
and there is most likely a bug elsewhere in the codebase.

we consider normalization a success as soon as we receive a txHash. This means there is a possibility
that the normalization can still fail, but the tx was valid when we sent it. These pledges will be re-normalized
the next time this is run.

@param {Array} pledges the ids of the pledges to normalize
@param {int} batchSize (optional) the size of the batch to chunk the requests into. Defaults to 20.
Normalize the provided pledges in chunks of ` batchSize ` . If a particular batch fails we will try again reducing the batch sized in half until we are only normalizing a single pledge . If a single pledge fails to normalize we will log the pledgeId and manual action will need to be taken . If a pledge fails to normalized 2x then the feathers cache is out of sync with what the blockchain knows and there is most likely a bug elsewhere in the codebase . we consider normalization a success as soon as we receive a txHash . This means there is a possibility that the normalization can still fail but the tx was valid when we sent it . These pledges will be re - normalized the next time this is run . @param { Array } pledges the ids of the pledges to normalize @param { int } batchSize ( optional ) the size of the batch to chunk the requests into . Defaults to 20 .
async function execute(pledges) {
    logger.info('normalizer execute() called', { pledges });
    if (pledges.length === 0) return;
    const opts = {
      from: web3.eth.accounts.wallet[0].address,
      $extraGas: 100000,
    };
    for (let i = 0; i < pledges.length; i += 1) {
      const pledge = pledges[i];
      try {
        logger.info(`Normalize pledge ${pledge}`);
        await sendTx(liquidPledging.normalizePledge, opts, pledge);
      } catch (e) {
        logger.error(`Error in normalizing pledge ${pledge} ->`, e);
      }
    }
  }
async function execute ( pledges ) { logger . info ( 'normalizer execute() called' , { pledges } ) ; if ( pledges . length === 0 ) return ; const opts = { from : web3 . eth . accounts . wallet [ 0 ] . address , $extraGas : 100000 , } ; for ( let i = 0 ; i < pledges . length ; i += 1 ) { const pledge = pledges [ i ] ; try { logger . info ( ` ${ pledge } ` ) ; await sendTx ( liquidPledging . normalizePledge , opts , pledge ) ; } catch ( e ) { logger . error ( ` ${ pledge } ` , e ) ; } } }
Normalize the provided pledges in chunks of `batchSize`.
Normalize the provided pledges in chunks of ` batchSize ` .
// eslint-disable-next-line no-await-in-loop