mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
27 lines
679 B
JavaScript
27 lines
679 B
JavaScript
const fs = require('fs');
|
|
|
|
function HotPocketContract() {
|
|
const hpargs = JSON.parse(fs.readFileSync(0, 'utf8'));
|
|
this.readonly = hpargs.readonly;
|
|
this.timestamp = hpargs.ts;
|
|
this.users = {};
|
|
|
|
Object.keys(hpargs.usrfd).forEach((userPubKey) => {
|
|
const userfds = hpargs.usrfd[userPubKey];
|
|
this.users[userPubKey] = new HotPocketChannel(userfds[0], userfds[1]);
|
|
});
|
|
}
|
|
|
|
function HotPocketChannel(infd, outfd) {
|
|
this.readInput = function () {
|
|
return infd == -1 ? null : fs.readFileSync(infd);
|
|
}
|
|
|
|
this.sendOutput = function (output) {
|
|
fs.writeFileSync(outfd, output);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
HotPocketContract
|
|
} |