npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ltonetwork/lto-chain-listener

v1.0.0

Published

LTO Public Chain listener

Downloads

1

Readme

github-banner

LTO Public Chain Listener

Listen to the public chain transactions of LTO Network

Quick Start

To listen to each transaction event, import the LTOChainListener and call start():

import LTOChainListener from 'lto-chain-listener';
// OR
const LTOChainListener = require('lto-chain-listener').default; // `.default` for CommonJS

const listener = new LTOChainListener(...options); // see available options below

// for now, the only event emitted is `new-transaction`
listener.on('new-transaction', (transaction) => {
  console.log('We have a new transaction!', transaction);
});

try {
  listener.start();
} catch (error) {
  // something bad happened, you can handle error here
}

- Options

The LTOChainListener accepts a few options for different behaviors. See the table below for reference:

| property | description | format | default value | | --------------------- | ----------------------------------------------------------------------------------------------------------- | ---------------------------------- | ------------------------------------------------------------------------------ | | processingHeight | The height the listener should start processing | Number | The value in local storage (localStorage.getItem('processingHeight')) or 1 | | publicNodeURL | The public node URL the listener should get data from | String | https://testnet.lto.network | | processIntervalInMS | The interval between each request made to the public node | Number (in milisseconds) | 5000 | | shouldRetryStart | Whether or not the listener should retry starting if it fails | Boolean | false | | testingMode | Whether or not the listener should run on testing mode (runs only once instead of listening for new blocks) | Boolean | false | | logLevel | The level of logging on the listener | info, error, warn or debug | info |

You can define these options as the following:

new LTOChainListener({
  processingHeight: 100,
  publicNodeURL: 'some-node-url',
  processIntervalInMS: 2000,
  shouldRetryStart: false,
  testingMode: true,
  logLevel: 'debug',
});

- Events

The chain listener emits events while it's processing blocks. For now, the only event emitted is new-transaction. You can listen to this event and run whichever code you want when a new transaction is found.

listener.on('new-transaction', (transaction) => {
  console.log('We have a new transaction!', transaction);
});

listener.start();

Note: it's important to run listener.start() only AFTER you create your listeners, otherwise they won't work properly

listener.start();

listener.on('new-transaction', (transaction) => {
  // this will not work, as it is created after `listener.start()`
});