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;
|
const chunkSize = 256;
|
||||||
let userdata = Buffer.alloc(chunkSize + 16);
|
|
||||||
let offset = 0;
|
let offset = 0;
|
||||||
let array = data;
|
let array = data;
|
||||||
|
const transactions = [];
|
||||||
while (array.length > 0) {
|
while (array.length > 0) {
|
||||||
const bytes = array.slice(0, chunkSize);
|
const bytes = array.slice(0, chunkSize);
|
||||||
|
let userdata = Buffer.alloc(chunkSize + 16);
|
||||||
userdataLayout.encode(
|
userdataLayout.encode(
|
||||||
{
|
{
|
||||||
instruction: 0, // Load instruction
|
instruction: 0, // Load instruction
|
||||||
@ -66,11 +66,12 @@ export class Loader {
|
|||||||
programId: this.programId,
|
programId: this.programId,
|
||||||
userdata,
|
userdata,
|
||||||
});
|
});
|
||||||
await sendAndConfirmTransaction(this.connection, program, transaction);
|
transactions.push(sendAndConfirmTransaction(this.connection, program, transaction));
|
||||||
|
|
||||||
offset += chunkSize;
|
offset += chunkSize;
|
||||||
array = array.slice(chunkSize);
|
array = array.slice(chunkSize);
|
||||||
}
|
}
|
||||||
|
await Promise.all(transactions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user