Skip to content
Snippets Groups Projects
Commit 89cc3810 authored by Robert Martin-Legene's avatar Robert Martin-Legene
Browse files

usa carpeta cache si existe

parent 9e0e5775
No related branches found
No related tags found
No related merge requests found
...@@ -10,12 +10,15 @@ var bfa = new Libbfa(); ...@@ -10,12 +10,15 @@ var bfa = new Libbfa();
var web3 = bfa.newweb3(); var web3 = bfa.newweb3();
var lastUnlock = 0; var lastUnlock = 0;
var netid = 0; var netid = 0;
var peerscache = bfa.networkdir + '/peers.cache';
if ( bfa.fs.existsSync( bfa.networkdir + '/cache' ) )
peerscache = bfa.networkdir + '/cache/peers.cache';
function readPeersCache() function readPeersCache()
{ {
if ( ! bfa.fs.existsSync( bfa.networkdir + '/peers.cache' ) ) if ( ! bfa.fs.existsSync( peerscache ) )
return []; return [];
var data = bfa.fs.readFileSync( bfa.networkdir + '/peers.cache' ).toString(); var data = bfa.fs.readFileSync( peerscache ).toString();
var p = []; var p = [];
if ( data.length > 0 ) if ( data.length > 0 )
p = data.split(/\r?\n/); p = data.split(/\r?\n/);
...@@ -32,11 +35,10 @@ function writePeersCache( peers ) ...@@ -32,11 +35,10 @@ function writePeersCache( peers )
if (peers.length > 100) if (peers.length > 100)
peers.splice( 0, peers.length - 100 ); peers.splice( 0, peers.length - 100 );
// peers.cache is a list of peers we have connected out to in the past. // peers.cache is a list of peers we have connected out to in the past.
var filename = bfa.networkdir + '/peers.cache';
var txt = peers.join("\n"); var txt = peers.join("\n");
if (txt.length > 0 && (txt.substring(txt.length-1) != "\n")) if (txt.length > 0 && (txt.substring(txt.length-1) != "\n"))
txt += "\n"; txt += "\n";
bfa.fs.writeFileSync( filename, txt, { mode: 0o644 } ); bfa.fs.writeFileSync( peerscache, txt, { mode: 0o644 } );
} }
function dnspeercachelookup() function dnspeercachelookup()
...@@ -212,7 +214,11 @@ function mayseal() ...@@ -212,7 +214,11 @@ function mayseal()
web3.bfa.clique.getSigners( web3.bfa.clique.getSigners(
function gotListOfSealers(e,x) function gotListOfSealers(e,x)
{ {
if (e) return; if (e)
{
console.error( e );
return;
}
var lcsealers = x.map( name => name.toLowerCase() ); var lcsealers = x.map( name => name.toLowerCase() );
var isSigner = (lcsealers.indexOf(me) > -1); var isSigner = (lcsealers.indexOf(me) > -1);
if ( isSigner ) if ( isSigner )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment