Compare commits

..

4 Commits

2 changed files with 6 additions and 8 deletions

View File

@ -32,12 +32,10 @@ class PluginAPI extends EventEmitter2 {
constructor({
config,
logger,
server,
swarm,
}: {
config: Config;
logger: Logger;
server: RPCServer;
swarm: any;
}) {
@ -47,7 +45,6 @@ class PluginAPI extends EventEmitter2 {
maxListeners: 0,
});
this._config = config;
this._logger = logger;
this._server = server;
this._swarm = swarm;
}
@ -74,10 +71,8 @@ class PluginAPI extends EventEmitter2 {
throw new Error("not implemented and should not be called");
}
private _logger: Logger;
get logger(): Logger {
return this._logger;
throw new Error("not implemented and should not be called");
}
get rpcServer(): RPCServer {
@ -115,7 +110,6 @@ export function getPluginAPI(): PluginAPI {
if (!pluginAPI) {
pluginAPI = new PluginAPI({
config,
logger: log,
server: getRpcServer(),
swarm: getSwarm(),
});
@ -212,6 +206,10 @@ export class PluginAPIManager {
});
}
if (prop === "logger") {
return log.child({ plugin: plugin.name });
}
return (target as any)[prop];
},
})

View File

@ -71,7 +71,7 @@ export class ProtocolManager {
this._swarm.on("connection", (peer: any) => {
for (const protocol of this._protocols) {
Protomux.from(peer).pair(
protocol[0],
{ protocol: protocol[0] },
this.handler.bind(this, protocol[0], peer)
);
}