Added so lighthouse gets the connection details from ~ config.
Added so lighthouse get the configuration for lbrycrdd from the ~/.lbrycrd/lbrycrd.conf file.
This commit is contained in:
parent
c026893c32
commit
58ca2ebc23
3 changed files with 45 additions and 13 deletions
|
@ -51,6 +51,7 @@
|
|||
"koa-router": "^7.0.0",
|
||||
"limited-request-queue": "^3.0.4",
|
||||
"ora": "^1.3.0",
|
||||
"properties-reader": "^0.0.16",
|
||||
"request": "^2.81.0",
|
||||
"request-promise": "^4.2.1",
|
||||
"winston": "^2.3.1",
|
||||
|
|
|
@ -12,6 +12,7 @@ import rp from 'request-promise';
|
|||
import appRoot from 'app-root-path';
|
||||
import fs from 'fs';
|
||||
import fileExists from 'file-exists';
|
||||
import PropertiesReader from 'properties-reader';
|
||||
|
||||
const loggerStream = winstonStream(winston, 'info');
|
||||
const eclient = new elasticsearch.Client({
|
||||
|
@ -24,23 +25,47 @@ const eclient = new elasticsearch.Client({
|
|||
},
|
||||
});
|
||||
const queue = new ElasticQueue({elastic: eclient});
|
||||
const client = new bitcoin.Client({
|
||||
host : 'localhost',
|
||||
port : 9245,
|
||||
user : 'lbry',
|
||||
pass : 'lbry',
|
||||
timeout: 30000,
|
||||
let client;
|
||||
|
||||
//Get the lbrycrd config from the .lbrycrd folder.
|
||||
fileExists(path.join(os.homedir(), '.lbrycrd/lbrycrd.conf'), (err, exists) => {
|
||||
if (err) { throw err };
|
||||
let config = {'username': 'lbry', 'password': 'lbry', 'rpc_port': 9245};
|
||||
if (exists) {
|
||||
let prop = PropertiesReader(path.join(os.homedir(), '.lbrycrd/lbrycrd.conf'));
|
||||
config.username = prop.get('rpcuser');
|
||||
config.password = prop.get('rpcpassword');
|
||||
config.rpc_port = prop.get('rpcport');
|
||||
client = new bitcoin.Client({
|
||||
host : 'localhost',
|
||||
port : config.rpc_port,
|
||||
user : config.username,
|
||||
pass : config.password,
|
||||
timeout: 30000,
|
||||
});
|
||||
} else {
|
||||
client = new bitcoin.Client({
|
||||
host : 'localhost',
|
||||
port : config.rpc_port,
|
||||
user : config.username,
|
||||
pass : config.password,
|
||||
timeout: 30000,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//Check that our cache file exist.
|
||||
fileExists(path.join(appRoot.path, 'claimTrieCache.json'), (err, exists) => {
|
||||
if (err) { throw err };
|
||||
if (!exists) {
|
||||
fs.writeFileSync(path.join(appRoot.path, 'claimTrieCache.json'), '[]');
|
||||
}
|
||||
});
|
||||
|
||||
let status = {};
|
||||
|
||||
export async function sync () {
|
||||
try {
|
||||
fileExists(path.join(appRoot.path, 'claimTrieCache.json'), (err, exists) => {
|
||||
if (err) { throw err };
|
||||
if (!exists) {
|
||||
fs.writeFileSync(path.join(appRoot.path, 'claimTrieCache.json'), '[]');
|
||||
}
|
||||
});
|
||||
status.info = 'Grabbing the claimTrie...';
|
||||
let claimTrie = await client.getClaimsInTrie().then(claimtrie => { return claimtrie }).catch(err => { throw err });
|
||||
let txList = [];
|
||||
|
|
|
@ -2553,7 +2553,7 @@ minimist@^1.2.0:
|
|||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
|
||||
|
||||
mkdirp@0.5.1, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1:
|
||||
mkdirp@0.5.1, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.1:
|
||||
version "0.5.1"
|
||||
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903"
|
||||
dependencies:
|
||||
|
@ -2920,6 +2920,12 @@ progress@^1.1.8:
|
|||
version "1.1.8"
|
||||
resolved "https://registry.yarnpkg.com/progress/-/progress-1.1.8.tgz#e260c78f6161cdd9b0e56cc3e0a85de17c7a57be"
|
||||
|
||||
properties-reader@^0.0.16:
|
||||
version "0.0.16"
|
||||
resolved "https://registry.yarnpkg.com/properties-reader/-/properties-reader-0.0.16.tgz#a2cc0db9cdd7b81d977d0a59c1dc10c6d1d6ab98"
|
||||
dependencies:
|
||||
mkdirp "~0.5.1"
|
||||
|
||||
ps-tree@^1.0.1:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/ps-tree/-/ps-tree-1.1.0.tgz#b421b24140d6203f1ed3c76996b4427b08e8c014"
|
||||
|
|
Loading…
Add table
Reference in a new issue