Fixed creation of claimTrieCache.json.

Fixes #22
This commit is contained in:
Fillerino 2017-09-26 18:11:40 +02:00
parent a81688ddd1
commit fd7f751523
3 changed files with 13 additions and 0 deletions

View file

@ -39,6 +39,7 @@
"chalk": "^2.0.1",
"elastic-queue": "^0.3.0",
"elasticsearch": "^13.2.0",
"file-exists": "^4.0.0",
"glob": "^7.1.1",
"jsonfile": "^3.0.1",
"jsonwebtoken": "^7.2.1",

View file

@ -10,6 +10,8 @@ import jsonfile from 'jsonfile';
import path from 'path';
import rp from 'request-promise';
import appRoot from 'app-root-path';
import fs from 'fs';
import fileExists from 'file-exists';
const loggerStream = winstonStream(winston, 'info');
const eclient = new elasticsearch.Client({
@ -33,6 +35,12 @@ 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 = [];

View file

@ -1472,6 +1472,10 @@ file-entry-cache@^2.0.0:
flat-cache "^1.2.1"
object-assign "^4.0.1"
file-exists@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/file-exists/-/file-exists-4.0.0.tgz#104eacf25d3fd6b3e462951ae923533195ffb52b"
filename-regex@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26"