2019-06-03 15:49:40 +02:00
|
|
|
const Web3 = require('web3')
|
|
|
|
|
2020-02-11 20:50:34 +03:00
|
|
|
const homeWeb3 = new Web3(new Web3.providers.HttpProvider('http://parity1:8545'))
|
|
|
|
const foreignWeb3 = new Web3(new Web3.providers.HttpProvider('http://parity2:8545'))
|
2019-08-05 14:13:16 +02:00
|
|
|
const {user, blockGenerator} = require('../constants.json');
|
|
|
|
|
2019-06-04 10:51:34 +02:00
|
|
|
homeWeb3.eth.accounts.wallet.add(user.privateKey)
|
|
|
|
foreignWeb3.eth.accounts.wallet.add(user.privateKey)
|
2019-08-05 14:13:16 +02:00
|
|
|
homeWeb3.eth.accounts.wallet.add(blockGenerator.privateKey)
|
|
|
|
foreignWeb3.eth.accounts.wallet.add(blockGenerator.privateKey)
|
2019-06-03 15:49:40 +02:00
|
|
|
|
2020-02-11 20:50:34 +03:00
|
|
|
function generateNewBlock(web3, address) {
|
|
|
|
return web3.eth.sendTransaction({
|
|
|
|
from: address,
|
|
|
|
to: '0x0000000000000000000000000000000000000000',
|
|
|
|
gasPrice: '1',
|
|
|
|
gas: '21000',
|
|
|
|
value: '1'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-06-03 15:49:40 +02:00
|
|
|
function main() {
|
|
|
|
setTimeout(async () => {
|
2020-02-11 20:50:34 +03:00
|
|
|
try {
|
|
|
|
generateNewBlock(homeWeb3, blockGenerator.address)
|
2020-07-14 21:53:05 +07:00
|
|
|
} catch (_) {} // in case of Transaction with the same hash was already imported.
|
2020-02-11 20:50:34 +03:00
|
|
|
try {
|
|
|
|
generateNewBlock(foreignWeb3, blockGenerator.address)
|
2020-07-14 21:53:05 +07:00
|
|
|
} catch (_) {} // in case of Transaction with the same hash was already imported.
|
2019-06-03 15:49:40 +02:00
|
|
|
main()
|
2019-08-05 14:13:16 +02:00
|
|
|
}, 1000)
|
2019-06-03 15:49:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
main()
|
|
|
|
|
|
|
|
process.on('SIGTERM', function () {
|
|
|
|
console.log('Finishing sending blocks...')
|
|
|
|
process.exit(0);
|
|
|
|
});
|