Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pls-pnv
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
plaasio
pls-pnv
Commits
d3b6c563
Commit
d3b6c563
authored
Feb 05, 2020
by
plaasio
👷🏽
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update pnv.js
parent
454a2893
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
5 deletions
+44
-5
pnv.js
pnv.js
+44
-5
No files found.
pnv.js
View file @
d3b6c563
...
...
@@ -3,12 +3,15 @@
//var PythonShell = require('python-shell');
let
{
PythonShell
}
=
require
(
'python-shell'
)
Promise
=
require
(
'promise'
);
request
=
require
(
'request'
);
//how much reward per valid share
vReward
=
0.1
;
shareFee
=
1
;
farmerReward
=
0.9
;
mainDomain
=
"https://plaas.io"
;
//how much gas fees per transaction
GasPrice
=
2000000000
;
...
...
@@ -30,7 +33,14 @@ var abi='[{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"co
async
function
getFarmerData
(
fID
){
request
(
mainDomain
+
'/fid/ertfgh'
,
function
(
error
,
response
,
body
)
{
if
(
error
)
return
error
;
if
(
response
)
return
response
;
});
}
function
getPySrc
(
src
,
args
){
...
...
@@ -60,22 +70,36 @@ async function init(){
var
pressed
=
await
getPySrc
(
'btns.py'
,
[]);
console
.
log
(
pressed
);
getPySrc
(
'lcd.py'
,
[
'READY'
,
'
scan contract
..'
]);
getPySrc
(
'lcd.py'
,
[
'READY'
,
'
add farmer
..'
]);
//var read = await getPySrc('rd-rfid.py', []);
//var write = await getPySrc('wt-rfid.py', ['value1', 'value2', 'value3']);
var
action
=
await
new
Promise
.
race
([
getPySrc
(
'rd-rfid.py'
,
[])]);
var
fID
=
await
new
Promise
.
race
([
getPySrc
(
'rd-rfid.py'
,
[])]);
// if
console
.
log
(
action
);
console
.
log
(
fID
);
getPySrc
(
'lcd.py'
,
[
'contracts ldg..'
,
fID
]);
var
fDet
=
await
getFarmerData
(
fID
);
getPySrc
(
'lcd.py'
,
[
'scanning cont..'
,
action
]);
var
shared
=
await
sendShare
(
''
,
''
,
action
);
console
.
log
(
shared
);
setTimeout
(
function
(){
init
();
},
3000
);
}
function
sendShare
(
pub
,
priv
,
share
){
...
...
@@ -165,9 +189,24 @@ try{
var
action
=
await
new
Promise
.
race
([
getPySrc
(
'rd-rfid.py'
,
[])]);
try
{
vAddressPublic
=
parse
(
action
).
pub
;
vAddressPrivate
=
parse
(
action
).
priv
;
getPySrc
(
'lcd.py'
,
[
'VALIDATOR ADDED'
,
'loading..'
]);
}
catch
(
err
){
//CODER BEWARE!
//this privatekey is burnt and should not be used for anything other than testing!!
console
.
warn
(
'WARNING! using test keys!'
);
vAddressPublic
=
'0xc5453b266F4FA4B9D3dA10C1Bd3a17b9b45516C6'
;
vAddressPrivate
=
'0x69cfb132b57816961a33da6c2eb223591d4d099c870dd906d86b059c18417832'
;
getPySrc
(
'lcd.py'
,
[
'VALIDATOR ADDED'
,
'testing..'
]);
}
init
();
}
catch
(
e
){
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment