-
Notifications
You must be signed in to change notification settings - Fork 66
/
index.js
72 lines (42 loc) · 1.59 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const Miner = require("./0xbitcoinminer-accel");
const miningLogger = require("./lib/mining-logger");
const fs = require('fs');
var pjson = require('./package.json');
//var minerConfig = require('./miner-config.json');
const { ethers } = require("ethers");
var ContractInterface = require("./contracts/DeployedContractInfo")
var NetworkInterface = require("./lib/network-interface");
var PoolInterface = require("./lib/pool-interface");
var provider ;
var wallet ;
var running = true;
console.log('Welcome to 0xBitcoin Miner!')
console.log('Version: ',pjson.version)
console.log('\n')
const minerConfigRaw = fs.readFileSync('./miner-config.json');
const minerConfig = JSON.parse(minerConfigRaw);
function loadConfig()
{
provider = new ethers.providers.JsonRpcProvider(minerConfig.web3provider);
wallet = new ethers.Wallet(minerConfig.mining_account_private_key, provider);
miningLogger.init();
//NetworkInterfaces
NetworkInterface.init(ethers, provider, wallet, miningLogger, minerConfig.contract_address, minerConfig.gas_price_gwei, minerConfig.priority_gas_fee_gwei);
PoolInterface.init(ethers, provider, wallet, miningLogger, minerConfig.contract_address, minerConfig.pool_url);
Miner.init( minerConfig.contract_address, ethers, wallet, miningLogger );
Miner.setNetworkInterface(NetworkInterface);
Miner.setPoolInterface(PoolInterface);
}
async function initMining()
{
Miner.mine(
minerConfig.mining_style,
wallet,
provider,
minerConfig.pool_url,
minerConfig.gas_price_gwei,
minerConfig.priority_gas_fee_gwei
)
}
loadConfig();
initMining();