mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
Implemented contract read requests. (#98)
This commit is contained in:
@@ -4,36 +4,45 @@ process.on('uncaughtException', (err) => {
|
||||
const fs = require('fs')
|
||||
|
||||
//console.log("===Sample contract started===");
|
||||
//console.log("Contract args received from hp: " + input);
|
||||
|
||||
let hpargs = JSON.parse(fs.readFileSync(0, 'utf8'));
|
||||
//console.log(hpargs);
|
||||
|
||||
// We just save execution args as an example state file change.
|
||||
fs.appendFileSync("exects.txt", "ts:" + hpargs.ts + "\n");
|
||||
if (!hpargs.readonly)
|
||||
fs.appendFileSync("exects.txt", "ts:" + hpargs.ts + "\n");
|
||||
|
||||
Object.keys(hpargs.usrfd).forEach(function (key, index) {
|
||||
let userfds = hpargs.usrfd[key];
|
||||
|
||||
if (userfds[0] != -1) {
|
||||
let userinput = fs.readFileSync(userfds[0], 'utf8');
|
||||
// Append user input to a state file.
|
||||
fs.appendFileSync("userinputs.txt", userinput + "\n");
|
||||
fs.writeSync(userfds[1], "Echoing: " + userinput);
|
||||
|
||||
// Append user input to a state file if not in read only mode.
|
||||
if (!hpargs.readonly)
|
||||
fs.appendFileSync("userinputs.txt", userinput + "\n");
|
||||
|
||||
if (userinput == "ts")
|
||||
fs.writeSync(userfds[1], fs.readFileSync("exects.txt"));
|
||||
else
|
||||
fs.writeSync(userfds[1], "Echoing: " + userinput);
|
||||
}
|
||||
});
|
||||
|
||||
if (hpargs.nplfd[0] != -1) {
|
||||
let nplinput = fs.readFileSync(hpargs.nplfd[0], 'utf8');
|
||||
console.log("Input received from peers:");
|
||||
console.log(nplinput);
|
||||
fs.writeSync(hpargs.nplfd[1], "Echoing: " + nplinput);
|
||||
}
|
||||
if (!hpargs.readonly) {
|
||||
|
||||
if (hpargs.hpfd[0] != -1) {
|
||||
let hpinput = fs.readFileSync(hpargs.hpfd[0], 'utf8');
|
||||
console.log("Input received from hp:");
|
||||
console.log(hpinput);
|
||||
fs.writeSync(hpargs.hpfd[1], "Echoing: " + hpinput);
|
||||
if (hpargs.nplfd[0] != -1) {
|
||||
let nplinput = fs.readFileSync(hpargs.nplfd[0], 'utf8');
|
||||
console.log("Input received from peers:");
|
||||
console.log(nplinput);
|
||||
fs.writeSync(hpargs.nplfd[1], "Echoing: " + nplinput);
|
||||
}
|
||||
|
||||
if (hpargs.hpfd[0] != -1) {
|
||||
let hpinput = fs.readFileSync(hpargs.hpfd[0], 'utf8');
|
||||
console.log("Input received from hp:");
|
||||
console.log(hpinput);
|
||||
fs.writeSync(hpargs.hpfd[1], "Echoing: " + hpinput);
|
||||
}
|
||||
}
|
||||
|
||||
//console.log("===Sample contract ended===");
|
||||
|
||||
Reference in New Issue
Block a user