-
Notifications
You must be signed in to change notification settings - Fork 66
/
gpuminer_test.js
77 lines (45 loc) · 1.73 KB
/
gpuminer_test.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
73
74
75
76
77
/*
In order to test basic GPU mining functions
Compile the C++ addon with
>>>> npm run build (this calls binding.gyp)
Run this file with
>>>> node indextestgpu.js
*/
/*
CURRENT ISSUE :
undefined symbol: device_map
this is in miner.h : ?
extern short device_map[MAX_GPUS];
this is in cuda_helper ?
extern "C" short device_map[MAX_GPUS];
https://github.com/tpruvot/ccminer/search?p=1&q=device_map&type=&utf8=%E2%9C%93 ?
*/
var web3utils = require('web3-utils');
//import C++ GPU miner code -- /cpp/gpuminer.cc
//const GPUMiner = require('./build/Release/gpuminer-addon-alpha');
const GPUMiner = require('./build/Release/gpuminer_addon');
var testNonce = 5566
var difficultyTarget = 5841053340
var challengeNumber = 2000
var ethAddress = '0x1234'
//send data into the miner
console.log('diff target' ,GPUMiner.setDifficultyTarget(difficultyTarget));
console.log('challenge number',GPUMiner.setChallengeNumber(challengeNumber));
console.log('eth address',GPUMiner.setEthAddress(ethAddress));
console.log('random number',GPUMiner.getRandomNumber());
console.log('keccak hash should be ', web3utils.soliditySha3(testNonce,ethAddress,challengeNumber) , GPUMiner.getKeccak256(testNonce,ethAddress,challengeNumber));
console.log('hashtest ', GPUMiner.testHashFunction(12345))
//start the infinite mining loop which is in c++
setInterval(function(){
console.log('asking GPU process for solutions...')
var gpu_solutions = GPUMiner.getSolutionsBuffer()
console.log(gpu_solutions);
var gpu_solutions = GPUMiner.clearSolutionsBuffer()
},2000)
setTimeout(function(){
var response = GPUMiner.startMining()
console.log(response)
},0)
/*
This code will eventually be moved into the file '0xbitcoinminer.js'
*/