@geekcash/smart-rpc
Advanced tools
Comparing version 1.0.7 to 1.0.8
@@ -1,1 +0,1 @@ | ||
module.exports=function(e){var t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(o,i,function(t){return e[t]}.bind(null,i));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t){e.exports=require("util")},function(e,t){e.exports=require("events")},function(e,t,n){"use strict";var o=function(e){return e&&e.__esModule?e:{default:e}}(n(3));var i=n(4),s=n(0),r=n(1).EventEmitter;function c(){r.call(this)}c.prototype={create:function(e){return new i(e)},listen:function(e){var t=this;Array.isArray(e)||(e=[e]);var n=this;this.clients=[];for(var i=0;i<e.length;i++){var s=e[i];if(!s.id)throw new Error("option.id is required");var r=this.create((0,o.default)(s,{listen:1}));this.clients.push(r)}for(var c=function(e){var o=t.clients[e];o.on("error",function(e){n.emit("error",o,e)}),o.on("hashblock",function(e){n.emit("hashblock",o,e)}),o.on("block",function(e){n.emit("block",o,e)}),o.on("rawtx",function(e){n.emit("rawtx",o,e)}),o.on("tx",function(e){n.emit("tx",o,e)})},a=0;a<this.clients.length;a++)c(a)}},s.inherits(c,r),e.exports=new c},function(e,t){e.exports=require("babel-runtime/core-js/object/assign")},function(e,t,n){"use strict";var o=function(e){return e&&e.__esModule?e:{default:e}}(n(5));var i=n(6),s=n(0),r=n(7),c=n(8),a=n(9),u=n(10),l=n(1).EventEmitter;function d(e){l.call(this),r.setLevel("info"),this.opts=e,this.id=e.id,this.apis=["abandonTransaction","addMultiSigAddress","addNode","backupWallet","clearBanned","createMultiSig","createRawTransaction","debug","decodeRawTransaction","decodeScript","disconnectNode","dumpPrivKey","dumpWallet","encryptWallet","estimateFee","estimatePriority","estimateSmartFee","estimateSmartPriority","fundRawTransaction","generate","getAccount","getAccountAddress","getAddressMempool","getAddressUtxos","getAddressBalance","getAddressDeltas","getAddressTxids","getAddressesByAccount","getAddedNodeInfo","getBalance","getBestBlockHash","getBlock","getBlockchainInfo","getBlockCount","getBlockHashes","getBlockHash","getBlockHeader","getBlockHeaders","getBlockTemplate","getConnectionCount","getChainTips","getDifficulty","getGenerate","getGovernanceInfo","getGovernanceInfo","getInfo","getMemPoolInfo","getMiningInfo","getNewAddress","getNetTotals","getNetworkInfo","getNetworkHashps","getPeerInfo","getPoolInfo","getRawMemPool","getRawChangeAddress","getRawTransaction","getReceivedByAccount","getReceivedByAddress","getSpentInfo","getSuperBlockBudget","getTransaction","getTxOut","getTxOutProof","getTxOutSetInfo","getWalletInfo","help","importAddress","instantSendToAddress","gobject","invalidateBlock","importPrivKey","importPubKey","importElectrumWallet","importWallet","keyPoolRefill","listAccounts","listAddressGroupings","listBanned","listReceivedByAccount","listReceivedByAddress","listSinceBlock","listTransactions","listUnspent","listLockUnspent","lockUnspent","masternode","masternodeBroadcast","masternodeList","mnsync","move","ping","prioritiseTransaction","privateSend","reconsiderBlock","resendWalletTransactions","sendFrom","sendMany","sendRawTransaction","sendToAddress","sentinelPing","setAccount","setBan","setGenerate","setTxFee","setMockTime","spork","signMessage","signRawTransaction","stop","submitBlock","validateAddress","verifyMessage","verifyChain","verifyTxOutProof","voteRaw","walletLock","walletPassPhrase","walletPassphraseChange"],this.transactions=a(5e3),this.transactionLocks=a(5e3),this.blocks=a(50),this.axios=i.create(e.rpc),this.axios.interceptors.response.use(function(e){return e&&e.data?e.data.result:null},function(e){return o.default.reject(e.response.data)}),this.init(),e.listen&&e.socket&&this.listen()}d.prototype={init:function(){for(var e=this,t=function(t){var n=e.apis[t];e[n]=function(){var e=[].slice.call(arguments);return this.axios.request({data:{jsonrpc:"2.0",method:n.toLowerCase(),params:e,id:(new Date).getTime()},maxContentLength:5e7,timeout:6e4})}},n=0;n<this.apis.length;n++)t(n);this._ready()},_ready:function(){var e=this;r.info("Check %s Daemon Ready",e.id,new Date),this.getBestBlockHash().then(function(t){e.getBlock(t).then(function(t){e.emit("ready"),r.info("%s Daemon Ready",e.id)}).catch(function(t){setTimeout(function(){e._ready()},5e3)})}).catch(function(t){setTimeout(function(){e._ready()},5e3)})},listen:function(){var e=this;this.socket=c.socket("sub"),this.socket.on("connect",function(e,t){r.info("ZMQ connected to:",t)}),this.socket.on("connect_delay",function(e,t){r.warn("ZMQ connection delay:",t)}),this.socket.on("disconnect",function(e,t){r.warn("ZMQ disconnect:",t)}),this.socket.on("monitor_error",function(t){r.error("Error in monitoring: %s, will restart monitoring in 5 seconds",t),setTimeout(function(){e.socket.monitor(500,0)},5e3)}),this.socket.subscribe("hashblock"),this.socket.subscribe("rawtx"),this.socket.subscribe("rawtxlock"),this.socket.on("message",function(t,n){switch(t.toString("utf8")){case"rawtxlock":var o=n.toString("hex"),i=u.md5(o);e.transactionLocks.get(i)||(e.transactionLocks.set(i,!0),e.decodeRawTransaction(o).then(function(t){e.emit("txlock",t)}));break;case"rawtx":o=n.toString("hex"),i=u.md5(o);e.transactions.get(i)||(e.transactions.set(i,!0),e.emit("rawtx",n),e.decodeRawTransaction(o).then(function(t){e.emit("tx",t)}));break;case"hashblock":o=n.toString("hex");e.blocks.get(o)||(e.blocks.set(o,!0),e.emit("hashblock",o),e.getBlock(o).then(function(t){e.emit("block",t)}))}}),r.info("Start monitoring..."),this.socket.monitor(500,0),this.socket.connect(this.opts.socket)}},s.inherits(d,l),e.exports=d},function(e,t){e.exports=require("babel-runtime/core-js/promise")},function(e,t){e.exports=require("axios")},function(e,t){e.exports=require("loglevel")},function(e,t){e.exports=require("zmq")},function(e,t){e.exports=require("lru-cache")},function(e,t){e.exports=require("mix-hash")}]); | ||
module.exports=function(e){var t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(o,i,function(t){return e[t]}.bind(null,i));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t){e.exports=require("util")},function(e,t){e.exports=require("events")},function(e,t,n){"use strict";var o=function(e){return e&&e.__esModule?e:{default:e}}(n(3));var i=n(4),r=n(0),s=n(1).EventEmitter;function c(){s.call(this)}c.prototype={create:function(e){return new i(e)},listen:function(e){var t=this;Array.isArray(e)||(e=[e]);var n=this;this.clients=[];for(var i=0;i<e.length;i++){var r=e[i];if(!r.id)throw new Error("option.id is required");var s=this.create((0,o.default)(r,{listen:1}));this.clients.push(s)}for(var c=function(e){var o=t.clients[e];o.on("error",function(e){n.emit("error",o,e)}),o.on("hashblock",function(e){n.emit("hashblock",o,e)}),o.on("block",function(e){n.emit("block",o,e)}),o.on("rawtx",function(e){n.emit("rawtx",o,e)}),o.on("tx",function(e){n.emit("tx",o,e)})},a=0;a<this.clients.length;a++)c(a)}},r.inherits(c,s),e.exports=new c},function(e,t){e.exports=require("babel-runtime/core-js/object/assign")},function(e,t,n){"use strict";var o=function(e){return e&&e.__esModule?e:{default:e}}(n(5));var i=n(6),r=n(0),s=n(7),c=n(8),a=n(9),u=n(10),l=n(1).EventEmitter;function d(e){l.call(this),s.setLevel("info"),this.opts=e,this.id=e.id,this.apis=["abandonTransaction","addMultiSigAddress","addNode","backupWallet","clearBanned","createMultiSig","createRawTransaction","debug","decodeRawTransaction","decodeScript","disconnectNode","dumpPrivKey","dumpWallet","encryptWallet","estimateFee","estimatePriority","estimateSmartFee","estimateSmartPriority","fundRawTransaction","generate","getAccount","getAccountAddress","getAddressMempool","getAddressUtxos","getAddressBalance","getAddressDeltas","getAddressTxids","getAddressesByAccount","getAddedNodeInfo","getBalance","getBestBlockHash","getBlock","getBlockchainInfo","getBlockCount","getBlockHashes","getBlockHash","getBlockHeader","getBlockHeaders","getBlockTemplate","getConnectionCount","getChainTips","getDifficulty","getGenerate","getGovernanceInfo","getGovernanceInfo","getInfo","getMemPoolInfo","getMiningInfo","getNewAddress","getNetTotals","getNetworkInfo","getNetworkHashps","getPeerInfo","getPoolInfo","getRawMemPool","getRawChangeAddress","getRawTransaction","getReceivedByAccount","getReceivedByAddress","getSpentInfo","getSuperBlockBudget","getTransaction","getTxOut","getTxOutProof","getTxOutSetInfo","getWalletInfo","help","importAddress","instantSendToAddress","gobject","invalidateBlock","importPrivKey","importPubKey","importElectrumWallet","importWallet","keyPoolRefill","listAccounts","listAddressGroupings","listBanned","listReceivedByAccount","listReceivedByAddress","listSinceBlock","listTransactions","listUnspent","listLockUnspent","lockUnspent","masternode","masternodeBroadcast","masternodeList","mnsync","move","ping","prioritiseTransaction","privateSend","reconsiderBlock","resendWalletTransactions","sendFrom","sendMany","sendRawTransaction","sendToAddress","sentinelPing","setAccount","setBan","setGenerate","setTxFee","setMockTime","spork","signMessage","signRawTransaction","stop","submitBlock","validateAddress","verifyMessage","verifyChain","verifyTxOutProof","voteRaw","walletLock","walletPassPhrase","walletPassphraseChange"],this.transactions=a(5e3),this.transactionLocks=a(5e3),this.blocks=a(50),this.retry=0,this.axios=i.create(e.rpc),this.axios.interceptors.response.use(function(e){return e&&e.data?e.data.result:null},function(e){return o.default.reject(e.response.data)}),this.init(),e.listen&&e.socket&&this.listen()}d.prototype={init:function(){for(var e=this,t=function(t){var n=e.apis[t];e[n]=function(){var e=[].slice.call(arguments);return this.axios.request({data:{jsonrpc:"2.0",method:n.toLowerCase(),params:e,id:(new Date).getTime()},maxContentLength:5e7,timeout:6e4})}},n=0;n<this.apis.length;n++)t(n);this._ready()},_ready:function(){var e=this;e.retry+=1,s.info("Check %s Daemon Ready",e.id,new Date),this.getBestBlockHash().then(function(t){e.getBlock(t).then(function(t){e.emit("ready"),s.info("%s Daemon Ready",e.id)}).catch(function(t){setTimeout(function(){e._ready()},5e3*e.retry)})}).catch(function(t){setTimeout(function(){e._ready()},5e3*e.retry)})},listen:function(){var e=this;this.socket=c.socket("sub"),this.socket.on("connect",function(e,t){s.info("ZMQ connected to:",t)}),this.socket.on("connect_delay",function(e,t){s.warn("ZMQ connection delay:",t)}),this.socket.on("disconnect",function(e,t){s.warn("ZMQ disconnect:",t)}),this.socket.on("monitor_error",function(t){s.error("Error in monitoring: %s, will restart monitoring in 5 seconds",t),setTimeout(function(){e.socket.monitor(500,0)},5e3)}),this.socket.subscribe("hashblock"),this.socket.subscribe("rawtx"),this.socket.subscribe("rawtxlock"),this.socket.on("message",function(t,n){switch(t.toString("utf8")){case"rawtxlock":var o=n.toString("hex"),i=u.md5(o);e.transactionLocks.get(i)||(e.transactionLocks.set(i,!0),e.decodeRawTransaction(o).then(function(t){e.emit("txlock",t)}));break;case"rawtx":o=n.toString("hex"),i=u.md5(o);e.transactions.get(i)||(e.transactions.set(i,!0),e.emit("rawtx",n),e.decodeRawTransaction(o).then(function(t){e.emit("tx",t)}));break;case"hashblock":o=n.toString("hex");e.blocks.get(o)||(e.blocks.set(o,!0),e.emit("hashblock",o),e.getBlock(o).then(function(t){e.emit("block",t)}))}}),s.info("Start monitoring..."),this.socket.monitor(500,0),this.socket.connect(this.opts.socket)}},r.inherits(d,l),e.exports=d},function(e,t){e.exports=require("babel-runtime/core-js/promise")},function(e,t){e.exports=require("axios")},function(e,t){e.exports=require("loglevel")},function(e,t){e.exports=require("zmq")},function(e,t){e.exports=require("lru-cache")},function(e,t){e.exports=require("mix-hash")}]); |
{ | ||
"name": "@geekcash/smart-rpc", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "Block and Transaction Real-Time Broadcasting in JavaScript.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -22,3 +22,3 @@ 'use strict'; | ||
this.blocks = LRU(50); | ||
this.retry = 0; | ||
this.axios = axios.create(option.rpc); | ||
@@ -74,2 +74,3 @@ | ||
var self = this; | ||
self.retry += 1; | ||
log.info('Check %s Daemon Ready', self.id, new Date()); | ||
@@ -83,4 +84,4 @@ this.getBestBlockHash().then((hash) => { | ||
self._ready(); | ||
}, 5000); | ||
return; | ||
}, self.retry * 5000); | ||
}); | ||
@@ -91,4 +92,4 @@ | ||
self._ready(); | ||
}, 5000); | ||
return; | ||
}, self.retry * 5000); | ||
}); | ||
@@ -95,0 +96,0 @@ |
38080