New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@aggregion/blockchain-mq

Package Overview
Dependencies
Maintainers
6
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aggregion/blockchain-mq

Blockchain message queue module

  • 1.0.13
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
6
Created
Source

BlockchainMQ

Usage xample

Using with mocks

const keySource = new MockKeySource();
const dataSource = new MockDataSource<string>();

const bmq = new BlockchainMQ({
  keySource,
  dataSource,
  ownKey: await keySource.getMyKey('my_org_id'),
  pollingInterval: 1000,
});

const topic = 56; // Some topic number

// Listening for new messages
const emitter = await bmq.poll<string>(topic);
let lastCursor;

emitter.on('message', (message) => {
    console.log(message);
});

emitter.on('newCursor', (cursor) => {
  lastCursor = cursor; // In production, you must save cursor and resume from this another time you need polling
});

await bmq.send<string>(
    topic, // Topic number
    'Hello!',
    'some_receiver_org_id',
);

// Broadcast message
await bmq.send<string>(
    topic,
    'Hello!'
);


emitter.stop(); // Stop polling

bmq.stopAll(); // You can use this method instead of calling "stop" of each emitter

Using with EOS blockchain

To use with the real blockchain, create client instance as follows (also look at blockchainMQ.e2e-spec.ts for example):

import { AggregionBlockchain } from '@aggregion/dmp-contracts';

const client = new AggregionBlockchain(nodeUrl, [
  pair1.privateKey,
  pair2.privateKey,
]);

const blockchainMQ = new BlockchainMQ({
  keySource: new EosKeySource({
    contractName: 'dmpusers',
    client: client,
  }),
  dataSource: new EosDataSource({
    contractName: 'dmpusers',
    client: client,
    clientAccount: 'your_orgId', // Id of your organization in orgsv2 table
  }),
  ownKey: {
    orgId: 'your_orgId',// Id of your organization in orgsv2 table
    data: 'your organization private key', // Not blockchain key! It is private part of public key saved in orgsv2 table
    format: KeyFormat.PKCS1_PEM,
    algo: KeyAlgo.RSA_4096,
  },
  pollingInterval: 500,
});

FAQs

Package last updated on 29 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc