feat: Submit program load transactions in parallel (#39)
feat: Submit program load transactions in parallel
This commit is contained in:
parent
bb0730f86e
commit
e1c2498f74
@ -46,12 +46,12 @@ export class Loader {
|
||||
]);
|
||||
|
||||
const chunkSize = 256;
|
||||
let userdata = Buffer.alloc(chunkSize + 16);
|
||||
let offset = 0;
|
||||
let array = data;
|
||||
const transactions = [];
|
||||
while (array.length > 0) {
|
||||
const bytes = array.slice(0, chunkSize);
|
||||
|
||||
let userdata = Buffer.alloc(chunkSize + 16);
|
||||
userdataLayout.encode(
|
||||
{
|
||||
instruction: 0, // Load instruction
|
||||
@ -66,11 +66,12 @@ export class Loader {
|
||||
programId: this.programId,
|
||||
userdata,
|
||||
});
|
||||
await sendAndConfirmTransaction(this.connection, program, transaction);
|
||||
transactions.push(sendAndConfirmTransaction(this.connection, program, transaction));
|
||||
|
||||
offset += chunkSize;
|
||||
array = array.slice(chunkSize);
|
||||
}
|
||||
await Promise.all(transactions);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user