@wavesenterprise/we-node-listener-service
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

WE Node listener service

Install

$ npm i @wavesenterprise/we-node-listener-service @wavesenterprise/we-node-grpc-api-nest

or

$ yarn add @wavesenterprise/we-node-listener-service @wavesenterprise/we-node-grpc-api-nest

Use

// app.module.ts
import { WeGrpcModule } from '@wavesenterprise/we-node-grpc-api-nest'
import { WeNodeListenerModule } from '@wavesenterprise/we-node-listener-service'
import { AppService } from './app.service'

@Module({
  imports: [
    WeGrpcModule.forRoot({
      address: NODE_ADDRESS,
      metadata: {
        authorization: 'api token',
      },
    }),
    WeNodeListenerModule.forRoot({
      reconnectDelay: 5000,
      reconnectOnClose: true,
      reconnectOnError: false,
      // Dead connection checks time since last received message
      deadConnectionCheckInterval: 5000,
      deadConnectionTimeout: 60000,
      reconnectOnDeadConnection: true,
      txFilter: [103, 104, 105],
    })
  ],
  providers: [AppService],
})
export class AppModule {
}
// app.service.ts
import { WeNodeListenerService } from '@wavesenterprise/we-node-listener-service'
import { Injectable, OnApplicationBootstrap } from '@nestjs/common'

@Injectable()
export class AppService implements OnApplicationBootstrap {

  constructor(
    private readonly nodeListenerService: WeNodeListenerService,
  ) {
  }

  async onApplicationBootstrap() {
    this.nodeListenerService.on('block', (data) => {
      this.nodeListenerService.setLastProcessedBlock(data.signature)
    })
    this.nodeListenerService.on('microblock', (data) => {
      // process microblock
    })
    this.nodeListenerService.on('rollbackCompleted', (data) => {
      this.nodeListenerService.setLastProcessedBlock(data.returnToBlockSignature)
    })
    await this.nodeListenerService.connect()
  }
}

Notes

Also emits raw stream events:
close
error
pause
resume
data

If deadConnectionTimeout and deadConnectionCheckInterval props are set, emits dead event

103, 104, 107 transactions are processed through 105 transaction and are merged with results and asset operations Any transaction within atomic is unwrapped and presented as independent 105 and 120 transactions are never emited

Package Sidebar

Install

npm i @wavesenterprise/we-node-listener-service

Weekly Downloads

0

Version

1.0.5

License

MIT

Unpacked Size

86.1 kB

Total Files

32

Last publish

Collaborators

  • stfy
  • sergeymart
  • nbugaev
  • wavesadmin
  • aklyavlin
  • dimalitvinov
  • mikhail.milekhin