Commit d3b6c563 authored by plaasio's avatar plaasio 👷🏽

Update pnv.js

parent 454a2893
......@@ -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){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment