Bundle import txs into blocks, wait for confirmations
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
b3dabb41e1
commit
96a18d3c5c
@ -1,6 +1,8 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const Kredits = require('../../lib/kredits');
|
const Kredits = require('../../lib/kredits');
|
||||||
|
|
||||||
|
const PARALLEL_TXS = 5;
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
kredits = new Kredits(hre.ethers.provider, hre.ethers.provider.getSigner())
|
kredits = new Kredits(hre.ethers.provider, hre.ethers.provider.getSigner())
|
||||||
await kredits.init();
|
await kredits.init();
|
||||||
@ -18,7 +20,19 @@ async function main() {
|
|||||||
const confirmationPeriod = 40320 // blocks
|
const confirmationPeriod = 40320 // blocks
|
||||||
const unconfirmedHeight = currentBlockHeight + confirmationPeriod;
|
const unconfirmedHeight = currentBlockHeight + confirmationPeriod;
|
||||||
|
|
||||||
for (const contributionId of ids) {
|
const txBundlesAmount = Math.ceil(ids.length / PARALLEL_TXS);
|
||||||
|
let txBundles = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < txBundlesAmount; i++) {
|
||||||
|
txBundles.push(ids.slice((i * PARALLEL_TXS), (i * PARALLEL_TXS) + PARALLEL_TXS));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const txBundle of txBundles) {
|
||||||
|
console.log(`Adding contributions #${txBundle[0]} to #${txBundle[txBundle.length - 1]}`)
|
||||||
|
|
||||||
|
let resultPromises = [];
|
||||||
|
|
||||||
|
for (const contributionId of txBundle) {
|
||||||
const c = contributions[contributionId.toString()];
|
const c = contributions[contributionId.toString()];
|
||||||
|
|
||||||
const confirmedAtBlock = c.confirmed ? currentBlockHeight : unconfirmedHeight;
|
const confirmedAtBlock = c.confirmed ? currentBlockHeight : unconfirmedHeight;
|
||||||
@ -28,9 +42,18 @@ async function main() {
|
|||||||
c.hashDigest, c.hashFunction, c.hashSize,
|
c.hashDigest, c.hashFunction, c.hashSize,
|
||||||
confirmedAtBlock, c.vetoed
|
confirmedAtBlock, c.vetoed
|
||||||
);
|
);
|
||||||
// await result.wait();
|
|
||||||
|
resultPromises.push(result.wait());
|
||||||
|
|
||||||
console.log(`Added contribution #${contributionId}: ${result.hash}`);
|
console.log(`Added contribution #${contributionId}: ${result.hash}`);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
console.log(`Waiting for confirmations...`);
|
||||||
|
|
||||||
|
await Promise.all(resultPromises);
|
||||||
|
|
||||||
|
console.log('Transactions confirmed');
|
||||||
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user