Skip to content

Commit

Permalink
Build 1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
emiliorizzo committed Jul 16, 2020
1 parent db00cd0 commit ce31e82
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 20 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Changelog

## [1.1.1] - 2020-07-16

### Changed

- Default config, remove logging to files as default
- blocksBalances service, get balances one by one.

### Added

- Log configuration instructions to README
- config.log.dir as PM2 log folder in blocks.config.js
- api.config.js, PM2 config file to start api

### Fixed

- Unhandled promise rejection on API start

## [1.1.0] - 2020-07-13

### Added
Expand Down
19 changes: 19 additions & 0 deletions dist/api/api.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.apps = void 0;var _config = _interopRequireDefault(require("../lib/config"));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}

const cwd = `${__dirname}`;
const name = 'explorer-api';
const script = 'index.js';
const { log } = _config.default;

const conf = { script, name, cwd };

if (log && log.dir) {
let { dir } = log;
conf.error_file = `${dir}/${name}-error.log`;
conf.out_file = `${dir}/${name}-out.log`;
}


const apps = [conf];exports.apps = apps;

console.log(apps);
2 changes: 1 addition & 1 deletion dist/api/modules/ContractVerification.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ContractVerification extends _DataCollector.DataCollectorItem {
* $ref: '#/responses/NotFound'
*/
getVerifiedContracts: params => {
params.fields = ['address'];
params.fields = { address: 1 };
let query = { match: true };
return this.getPageData(query, params);
},
Expand Down
7 changes: 4 additions & 3 deletions dist/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ function makeConfig(config = {}) {
config.blocks.source = config.source;

// defaults log files

defaultLogs('api');
defaultLogs('blocks');
if (config.log.logToFiles === true) {
defaultLogs('api');
defaultLogs('blocks');
}

config.api.collectionsNames = config.collectionsNames;
return config;
Expand Down
3 changes: 2 additions & 1 deletion dist/lib/defaultConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ reduce((a, v, i) => {
},
log: {
dir: '/var/log/rsk-explorer',
level: 'info' },
level: 'info',
logToFiles: false },

db: {
server: 'localhost',
Expand Down
12 changes: 10 additions & 2 deletions dist/services/blocks.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.apps = exports.paths = void 0;
var _servicesConfig = require("./servicesConfig");
var _config = _interopRequireDefault(require("../lib/config"));
var _servicesConfig = require("./servicesConfig");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}

const scripts = Object.values(_servicesConfig.servicesNames);

const scriptName = name => `${name}.js`;

const cwd = `${__dirname}/blocks/`;
const { log } = _config.default;

const paths = scripts.map(name => cwd + scriptName(name));exports.paths = paths;

const apps = scripts.map(name => {
let script = scriptName(name);
return { name, script, cwd };
let conf = { name, script, cwd };
if (log && log.dir) {
let { dir } = log;
conf.error_file = `${dir}/${name}-error.log`;
conf.out_file = `${dir}/${name}-out.log`;
}
return conf;
});exports.apps = apps;
7 changes: 4 additions & 3 deletions dist/services/classes/BlockBalances.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ class BlockBalances extends _BcThing.BcThing {
try {
if (this.balances) return this.balances;
let { addresses, blockHash, blockNumber, timestamp } = this;
let balances = await Promise.all(addresses.map(async Addr => {
const balances = [];
for (let Addr of addresses) {
let { address } = Addr;
let balance = await Addr.getBalance(blockNumber);
balance = parseInt(balance) ? balance : 0;
let _created = Date.now();
return { address, balance, blockHash, blockNumber, timestamp, _created };
}));
balances.push({ address, balance, blockHash, blockNumber, timestamp, _created });
}
this.balances = balances;
return this.balances;
} catch (err) {
Expand Down
6 changes: 5 additions & 1 deletion dist/services/userEvents/ContractVerifierModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ function ContractVerifierModule(db, collections, { url } = {}, { log } = {}) {
case 'versions':
log.debug(`Updating solc versions list`);
versions = Object.assign({}, data);
storedConfig.update(versionsId, versions, { create: true });
// temporal solution to '.' in field names
await storedConfig.update(versionsId, {}, { create: true });
storedConfig.update(versionsId, versions).catch(err => {
log.warn(err);
});
break;
// verification result
case 'verify':
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rsk-explorer-api",
"version": "1.1.0",
"version": "1.1.1",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion public/swagger.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"info": {
"title": "rsk-explorer-api",
"version": "1.1.0",
"version": "1.1.1",
"description": "explorer API Documentation"
},
"swagger": "2.0",
Expand Down

0 comments on commit ce31e82

Please sign in to comment.