Skip to content

Commit

Permalink
node: require bindings or user-set backend
Browse files Browse the repository at this point in the history
  • Loading branch information
pinheadmz committed Mar 14, 2019
1 parent 2b2e53d commit 67702c3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/node/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const Logger = require('blgr');
const Config = require('bcfg');
const Network = require('../protocol/network');
const WorkerPool = require('../workers/workerpool');
const sha256 = require('bcrypto/lib/sha256');

/**
* Node
Expand Down Expand Up @@ -187,6 +188,16 @@ class Node extends EventEmitter {
this.logger.warning('Warning: worker pool is disabled.');
this.logger.warning('Verification will be slow.');
}

// native: 0 = js, 1 = node, 2 = bindings
if (sha256.native !== 2 &&
process.env.NODE_BACKEND !== 'js' &&
process.env.NODE_BACKEND !== 'node'
) {
throw new Error(
'No bcrypto bindings. Must explicitly set `NODE_BACKEND=<js|node>`'
);
}
}

/**
Expand Down

0 comments on commit 67702c3

Please sign in to comment.