Skip to content

Commit

Permalink
fix(node): config should use merge, findOneAndUpdate should return new
Browse files Browse the repository at this point in the history
lodash merge is more in mind with the goal of config's setup. There is an issue with using the state
model's syncing node initially, likely do the original data being returned, which would result in an
error
  • Loading branch information
micahriggan committed Jan 7, 2019
1 parent 766005d commit 8ecd8d6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/bitcore-node/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { homedir, cpus } from 'os';
import parseArgv from './utils/parseArgv';
import { ConfigType } from './types/Config';
import * as _ from 'lodash';
let program = parseArgv([], ['config']);

function findConfig(): ConfigType | undefined {
Expand Down Expand Up @@ -76,7 +77,7 @@ const Config = function(): ConfigType {
};

let foundConfig = findConfig();
Object.assign(config, foundConfig, {});
config = _.merge(config, foundConfig, {});
if (!Object.keys(config.chains).length) {
Object.assign(config.chains, {
BTC: {
Expand Down
2 changes: 1 addition & 1 deletion packages/bitcore-node/src/models/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class StateModel extends BaseModel<IState> {
return this.collection.findOneAndUpdate(
{},
{ $setOnInsert: { created: new Date()}},
{ upsert: true }
{ upsert: true, returnOriginal: false }
);
}

Expand Down

0 comments on commit 8ecd8d6

Please sign in to comment.