fix: add timing constants to better set timeouts

This commit is contained in:
Michael Vines
2019-03-05 09:53:56 -08:00
parent 243a4625f1
commit f655c30159
3 changed files with 24 additions and 6 deletions

View File

@ -4,8 +4,10 @@ import * as BufferLayout from 'buffer-layout';
import {Account} from './account';
import {PublicKey} from './publickey';
import {NUM_TICKS_PER_SECOND} from './timing';
import {Transaction} from './transaction';
import {sendAndConfirmTransaction} from './util/send-and-confirm-transaction';
import {sleep} from './util/sleep';
import type {Connection} from './connection';
/**
@ -81,6 +83,10 @@ export class Loader {
sendAndConfirmTransaction(this.connection, transaction, program),
);
// Delay ~1 tick between write transactions in an attempt to reduce AccountInUse errors
// since all the write transactions modify the same program account
await sleep(1000 / NUM_TICKS_PER_SECOND);
// Run up to 8 Loads in parallel to prevent too many parallel transactions from
// getting rejected with AccountInUse.
//