Browse Source

Merge pull request #511 from chjj/fix_paypro_example

paypro: fix example server for no-tx argument.
patch-2
Ryan X. Charles 11 years ago
parent
commit
0dd078a280
  1. 65
      examples/PayPro/server.js

65
examples/PayPro/server.js

@ -299,39 +299,40 @@ app.post('/-/pay', function(req, res, next) {
return ptx; return ptx;
}); });
(function retry() { if (!argv['no-tx']) {
var timeout = setTimeout(function() { (function retry() {
if (conn) { var timeout = setTimeout(function() {
transactions.forEach(function(tx) { if (conn) {
var id = tx.getHash().toString('hex'); transactions.forEach(function(tx) {
print(''); var id = tx.getHash().toString('hex');
print('Sending transaction with txid: %s', id); print('');
print(tx.getStandardizedObject()); print('Sending transaction with txid: %s', id);
print(tx.getStandardizedObject());
var pending = 1;
peerman.on('ack', function listener() { print('Broadcasting transaction...');
if (!--pending) {
peerman.removeListener('ack', listener); var pending = 1;
clearTimeout(timeout); peerman.on('ack', function listener() {
print('Transaction sent to peer successfully.'); if (!--pending) {
} peerman.removeListener('ack', listener);
}); clearTimeout(timeout);
print('Transaction sent to peer successfully.');
print('Broadcasting transaction...'); res.send(ack);
}
if (!argv['no-tx']) { });
conn.sendTx(tx); conn.sendTx(tx);
} });
}); } else {
} else { print('No BTC network connection. Retrying...');
print('No BTC network connection. Retrying...'); conn = peerman.getActiveConnection();
conn = peerman.getActiveConnection(); retry();
retry(); }
} }, 1000);
}, 1000); })();
})(); } else {
print('Broadcasting transaction...');
res.send(ack); res.send(ack);
}
}); });
/** /**

Loading…
Cancel
Save