Browse Source

create rpc client at startup and keep it around

fix-133-memory-crash
Dan Janosik 7 years ago
parent
commit
28d621fc4a
  1. 22
      app.js

22
app.js

@ -87,6 +87,18 @@ app.runOnStartup = function() {
console.log("Running RPC Explorer for coin: " + global.coinConfig.name); console.log("Running RPC Explorer for coin: " + global.coinConfig.name);
if (env.rpc) {
console.log("Connecting via RPC to node at " + env.rpc.host + ":" + env.rpc.port);
global.client = new bitcoinCore({
host: env.rpc.host,
port: env.rpc.port,
username: env.rpc.username,
password: env.rpc.password,
timeout: 5000
});
}
if (env.donationAddresses) { if (env.donationAddresses) {
var getDonationAddressQrCode = function(coinId) { var getDonationAddressQrCode = function(coinId) {
qrcode.toDataURL(env.donationAddresses[coinId].address, function(err, url) { qrcode.toDataURL(env.donationAddresses[coinId].address, function(err, url) {
@ -135,18 +147,10 @@ app.use(function(req, res, next) {
res.locals.session = req.session; res.locals.session = req.session;
res.locals.debug = env.debug; res.locals.debug = env.debug;
if (env.rpc) { if (env.rpc && req.session.host == null) {
req.session.host = env.rpc.host; req.session.host = env.rpc.host;
req.session.port = env.rpc.port; req.session.port = env.rpc.port;
req.session.username = env.rpc.username; req.session.username = env.rpc.username;
global.client = new bitcoinCore({
host: env.rpc.host,
port: env.rpc.port,
username: env.rpc.username,
password: env.rpc.password,
timeout: 5000
});
} }
res.locals.env = global.env; res.locals.env = global.env;

Loading…
Cancel
Save