origintrail-node
Version:
OriginTrail Node - Decentralized Knowledge Graph Node Library
101 lines (85 loc) • 2.6 kB
JavaScript
import BaseModuleManager from '../base-module-manager.js';
class NetworkModuleManager extends BaseModuleManager {
getName() {
return 'network';
}
async start() {
if (this.initialized) {
return this.getImplementation().module.start();
}
}
async onPeerConnected(listener) {
if (this.initialized) {
return this.getImplementation().module.onPeerConnected(listener);
}
}
getMultiaddrs() {
if (this.initialized) {
return this.getImplementation().module.getMultiaddrs();
}
}
getPeers() {
if (this.initialized) {
return this.getImplementation().module.getPeers();
}
}
async sendMessage(protocol, remotePeerId, messageType, operationId, message, timeout) {
if (this.initialized) {
return this.getImplementation().module.sendMessage(
protocol,
remotePeerId,
messageType,
operationId,
message,
timeout,
);
}
}
async sendMessageResponse(protocol, remotePeerId, messageType, operationId, message) {
if (this.initialized) {
return this.getImplementation().module.sendMessageResponse(
protocol,
remotePeerId,
messageType,
operationId,
message,
);
}
}
handleMessage(protocol, handler, options) {
if (this.initialized) {
this.getImplementation().module.handleMessage(protocol, handler, options);
}
}
getPeerId() {
if (this.initialized) {
return this.getImplementation().module.getPeerId();
}
}
async healthCheck() {
if (this.initialized) {
return this.getImplementation().module.healthCheck();
}
}
async findPeer(peerId) {
if (this.initialized) {
return this.getImplementation().module.findPeer(peerId);
}
}
async dial(peerId) {
if (this.initialized) {
return this.getImplementation().module.dial(peerId);
}
}
async getPeerInfo(peerId) {
if (this.initialized) {
return this.getImplementation().module.getPeerInfo(peerId);
}
}
removeCachedSession(operationId, remotePeerId) {
if (this.initialized) {
this.getImplementation().module.removeCachedSession(operationId, remotePeerId);
}
}
}
export default NetworkModuleManager;