2019-06-03 16:49:40 +03:00
|
|
|
const Web3 = require('web3')
|
2019-06-04 11:28:11 +03:00
|
|
|
const { generateNewBlock } = require('../utils')
|
2019-06-03 16:49:40 +03:00
|
|
|
|
|
|
|
const homeWeb3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8541'))
|
|
|
|
const foreignWeb3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8542'))
|
2019-08-05 15:13:16 +03:00
|
|
|
const {user, blockGenerator} = require('../constants.json');
|
|
|
|
|
2019-06-04 11:51:34 +03:00
|
|
|
homeWeb3.eth.accounts.wallet.add(user.privateKey)
|
|
|
|
foreignWeb3.eth.accounts.wallet.add(user.privateKey)
|
2019-08-05 15:13:16 +03:00
|
|
|
homeWeb3.eth.accounts.wallet.add(blockGenerator.privateKey)
|
|
|
|
foreignWeb3.eth.accounts.wallet.add(blockGenerator.privateKey)
|
2019-06-03 16:49:40 +03:00
|
|
|
|
|
|
|
function main() {
|
|
|
|
setTimeout(async () => {
|
2019-08-05 15:13:16 +03:00
|
|
|
generateNewBlock(homeWeb3, blockGenerator.address)
|
|
|
|
generateNewBlock(foreignWeb3, blockGenerator.address)
|
2019-06-03 16:49:40 +03:00
|
|
|
main()
|
2019-08-05 15:13:16 +03:00
|
|
|
}, 1000)
|
2019-06-03 16:49:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
main()
|
|
|
|
|
|
|
|
process.on('SIGTERM', function () {
|
|
|
|
console.log('Finishing sending blocks...')
|
|
|
|
process.exit(0);
|
|
|
|
});
|