Skip to content

Commit

Permalink
Catch fs exception
Browse files Browse the repository at this point in the history
  • Loading branch information
MoneroOcean committed May 8, 2024
1 parent 15a4927 commit 41211e2
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions lib/pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -2568,27 +2568,25 @@ if (cluster.isMaster) {
let numWorkers = require('os').cpus().length;
for (let i = 1; i <= numWorkers; ++ i) {
let fn = "wallet_trust_" + i.toString();
try {
let lineReader = require('readline').createInterface({ input: fs.createReadStream(fn) });
lineReader.on('error', function() { console.error("Can't read lines from " + fn + " file"); });
lineReader.on('line', function (line) {
let parts = line.split(/\t/);
if (parts.length != 3) {
console.error("Error line " + line + " ignored from " + fn + " file");
return;
}
let wallet = parts[0];
let trust = parseInt(parts[1], 10);
let time = parseInt(parts[2], 10);
if (Date.now() - time < 24*60*60*1000 && (!(wallet in walletTrust) || trust < walletTrust[wallet])) {
debug("Adding " + trust.toString() + " trust for " + wallet + " wallet");
walletTrust[wallet] = trust;
walletLastSeeTime[wallet] = time;
}
});
} catch(e) {
console.error("Can't open " + fn + " file");
}
let rs = fs.createReadStream(fn);
rs.on('error', function() { console.error("Can't open " + fn + " file"); });
let lineReader = require('readline').createInterface({ input: rs });
lineReader.on('error', function() { console.error("Can't read lines from " + fn + " file"); });
lineReader.on('line', function (line) {
let parts = line.split(/\t/);
if (parts.length != 3) {
console.error("Error line " + line + " ignored from " + fn + " file");
return;
}
let wallet = parts[0];
let trust = parseInt(parts[1], 10);
let time = parseInt(parts[2], 10);
if (Date.now() - time < 24*60*60*1000 && (!(wallet in walletTrust) || trust < walletTrust[wallet])) {
debug("Adding " + trust.toString() + " trust for " + wallet + " wallet");
walletTrust[wallet] = trust;
walletLastSeeTime[wallet] = time;
}
});
}

// dump wallet trust and miner agents to file
Expand Down

0 comments on commit 41211e2

Please sign in to comment.