{"_id":"@alayanetwork/eth-block-tracker","_rev":"1-8418c44a2b0eed4fcd8f765a78f4b2f4","name":"@alayanetwork/eth-block-tracker","dist-tags":{"latest":"4.4.3"},"versions":{"4.4.3":{"name":"@alayanetwork/eth-block-tracker","version":"4.4.3","description":"A block tracker for the PlatON blockchain. Keeps track of the latest block.","main":"src/polling.js","scripts":{"lint":"eslint --ext .js .","test":"yarn build && yarn test:unit && yarn test:lint:deps","test:unit":"node test/index.js","test:lint:deps":"npx depcheck --ignore-dirs dist --ignores babelify,@babel/runtime,@babel/preset-env,@babel/plugin-transform-runtime","prepublishOnly":"yarn run build","build":"yarn build:clean && yarn build:es5 && yarn build:bundle && yarn build:validate","build:clean":"rm -rf ./dist && mkdir -p ./dist","build:es5":"babel ./src -d dist/es5/","build:bundle":"yarn build:bundle:polling && yarn build:bundle:base && yarn build:bundle:subscribe","build:bundle:polling":"browserify -s PollingBlockTracker -e src/polling.js -g babelify > dist/PollingBlockTracker.js","build:bundle:subscribe":"browserify -s SubscribeBlockTracker -e src/subscribe.js -g babelify > dist/SubscribeBlockTracker.js","build:bundle:base":"browserify -s BaseBlockTracker -e src/base.js -g babelify > dist/BaseBlockTracker.js","build:validate":"uglifyjs dist/es5/**.js > /dev/null"},"license":"MIT","resolutions":{"ganache-core/**/elliptic":"^6.5.3","ganache-core/lodash":"^4.17.19"},"dependencies":{"@babel/plugin-transform-runtime":"^7.5.5","@babel/runtime":"^7.5.5","json-rpc-random-id":"^1.0.1","pify":"^3.0.0","safe-event-emitter":"^1.0.1"},"devDependencies":{"@babel/cli":"^7.5.5","@babel/core":"^7.5.5","@babel/plugin-transform-regenerator":"^7.4.5","@babel/preset-env":"^7.5.5","@metamask/eslint-config":"^3.0.0","babelify":"^10.0.0","browserify":"^16.5.0","eslint":"^6.8.0","eslint-plugin-import":"^2.20.1","ganache-core":"^2.7.0","tape":"^4.9.0","uglify-js":"^3.4.10"},"directories":{"test":"test"},"repository":{"type":"git","url":"git+https://github.com/AlayaNetwork/samurai-eth-block-tracker.git"},"bugs":{"url":"https://github.com/AlayaNetwork/samurai-eth-block-tracker/issues"},"homepage":"https://github.com/AlayaNetwork/samurai-eth-block-tracker#readme","gitHead":"ba6355c9e164c1819f217f62e5b2c0d1f3d43a6b","_id":"@alayanetwork/eth-block-tracker@4.4.3","_nodeVersion":"14.12.0","_npmVersion":"6.14.8","dist":{"integrity":"sha512-bEkY0pu0RfaI4y++PE29tvw+wRfR7oPiwTwpaA+vmY3N9eV8Hi2bTwy00MSNFY2IyfscVOg32ltONIqUDi3pUA==","shasum":"a0fd1f9231f4175e14ba6b8bb05b0a47c122d24d","tarball":"https://registry.npmjs.org/@alayanetwork/eth-block-tracker/-/eth-block-tracker-4.4.3.tgz","fileCount":25,"unpackedSize":307682,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfooJwCRA9TVsSAnZWagAAQuUQAIVPWh4/GemBMUzHGXRU\nZS6YgYV5TyVUp9O5HHwDsvf6EqPxWz7KqhYLVgGQ1/4jXeAd5IZ/JQgNUvvS\n2zj5syk86UROxrwQggn2dzXGHgzOe14NWP29ijbRNeJZrSJ5S/ZwbnnGYOoy\nWHCoC+gopy7QTu9FRV3uRzzuvDUibQiIEihg32XbVBK+YMnf4lxjfdSrTcxA\nYPyD6X7f3YK46ymRz+BFO5NwvxIxBJajjqrYDcWBliZiohHHhgV6rw+aZIDP\nd+RjdQ0YfJH2suEw+vUuQAsMxSswzPbWlgkbxNL29cOBPvxChOabgpHNoTrg\nChNoGWQ1naa3iSTiVmzu54eL3rlcO0paNLq5DMtGIhStLTQgOzHl/0tL9EHX\nELN21rFLviWwkKWWOuqc843IvFiSH3RgZQEAFPDmPzWiDH+5KhK7UWrGiBcD\n822cwgEozkskOFIg6zFbFOu8pOVUUVK3nfyvlYajU48uSyrMhg8/XJUWuUZG\nN3lGXCZ+afvcNVteyvJhUJQPVe1sMfetXVe9POtPsAQQj23L1SlA8IYOPb8d\nEmJRy7s/iIToEjP2Zcy6ni7Kd/DNSfXv8nYRa79MSsrZFH73zBRNPowiBK3g\nGFQur4LA6/340H8jJM3zFct6kdpt9Cbv+b195Ee3UjN6256fZEJb314gkMkm\nn3Th\r\n=JncV\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDzqAnxAfjE9O53UfggFtlxJrC1HnbY0Xtrq7/E9NXR1AiA8Ii7aSH084FLkjqppGsrkeoHe0ppxqeLrdLTQmDRU8g=="}]},"_npmUser":{"name":"alayanetwork","email":"npm@latticex.foundation"},"maintainers":[{"name":"alayanetwork","email":"npm@latticex.foundation"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eth-block-tracker_4.4.3_1604485743516_0.15886497865155724"},"_hasShrinkwrap":false}},"time":{"created":"2020-11-04T10:29:03.450Z","4.4.3":"2020-11-04T10:29:03.641Z","modified":"2022-04-04T12:33:51.960Z"},"maintainers":[{"name":"alayanetwork","email":"npm@latticex.foundation"}],"description":"A block tracker for the PlatON blockchain. Keeps track of the latest block.","homepage":"https://github.com/AlayaNetwork/samurai-eth-block-tracker#readme","repository":{"type":"git","url":"git+https://github.com/AlayaNetwork/samurai-eth-block-tracker.git"},"bugs":{"url":"https://github.com/AlayaNetwork/samurai-eth-block-tracker/issues"},"license":"MIT","readme":"\n# eth-block-tracker\n\nThis module walks the Ethereum blockchain, keeping track of the latest block.\nIt uses a web3 provider as a data source and will continuously poll for the next block.\n\n```js\nconst createInfuraProvider = require('eth-json-rpc-infura')\nconst PollingBlockTracker = require('eth-block-tracker')\n\nconst provider = createInfuraProvider({ network: 'mainnet', projectId: process.env.INFURA_PROJECT_ID })\nconst blockTracker = new PollingBlockTracker({ provider })\n\nblockTracker.on('sync', ({ newBlock, oldBlock }) => {\n  if (oldBlock) {\n    console.log(`sync #${Number(oldBlock)} -> #${Number(newBlock)}`)\n  } else {\n    console.log(`first sync #${Number(newBlock)}`)\n  }\n})\n```\n\n### methods\n\n##### new PollingBlockTracker({ provider, pollingInterval, retryTimeout, keepEventLoopActive })\n\ncreates a new block tracker with `provider` as a data source and\n`pollingInterval` (ms) timeout between polling for the latest block.\nIf an Error is encountered when fetching blocks, it will wait `retryTimeout` (ms) before attempting again.\nIf `keepEventLoopActive` is false, in Node.js it will [unref the polling timeout](https://nodejs.org/api/timers.html#timers_timeout_unref), allowing the process to exit during the polling interval. defaults to `true`, meaning the process will be kept alive.\n\n##### getCurrentBlock()\n\nsynchronous returns the current block. may be `null`.\n\n```js\nconsole.log(blockTracker.getCurrentBlock())\n```\n\n##### async getLatestBlock()\n\nAsynchronously returns the latest block.\nif not immediately available, it will fetch one.\n\n##### async checkForLatestBlock()\n\nTells the block tracker to ask for a new block immediately, in addition to its normal polling interval.\nUseful if you received a hint of a new block (e.g. via `tx.blockNumber` from `getTransactionByHash`).\nWill resolve to the new latest block when its done polling.\n\n### EVENTS\n\n##### latest\n\nThe `latest` event is emitted for whenever a new latest block is detected.\nThis may mean skipping blocks if there were two created since the last polling period.\n\n```js\nblockTracker.on('latest', (newBlock) => console.log(newBlock))\n```\n\n##### sync\n\nThe `sync` event is emitted the same as \"latest\" but includes the previous block.\n\n```js\nblockTracker.on('sync', ({ newBlock, oldBlock }) => console.log(newBlock, oldBlock))\n```\n\n##### error\n\nThe `error` event means an error occurred while polling for the latest block.\n\n```js\nblockTracker.on('error', (err) => console.error(err))\n```\n\n### NOTES\n\nVersion 4.x.x differs significantly from version 3.x.x\n\nPlease see the [CHANGELOG](./CHANGELOG.md).\n","readmeFilename":"README.md"}