Compare commits
4 Commits
90d8bfba63
...
d3d0f387b6
Author | SHA1 | Date |
---|---|---|
Derrick Hammer | d3d0f387b6 | |
Derrick Hammer | eb2a19121f | |
Derrick Hammer | d5138c3860 | |
Derrick Hammer | 594e8d82a1 |
|
@ -32,12 +32,10 @@ class PluginAPI extends EventEmitter2 {
|
||||||
|
|
||||||
constructor({
|
constructor({
|
||||||
config,
|
config,
|
||||||
logger,
|
|
||||||
server,
|
server,
|
||||||
swarm,
|
swarm,
|
||||||
}: {
|
}: {
|
||||||
config: Config;
|
config: Config;
|
||||||
logger: Logger;
|
|
||||||
server: RPCServer;
|
server: RPCServer;
|
||||||
swarm: any;
|
swarm: any;
|
||||||
}) {
|
}) {
|
||||||
|
@ -47,7 +45,6 @@ class PluginAPI extends EventEmitter2 {
|
||||||
maxListeners: 0,
|
maxListeners: 0,
|
||||||
});
|
});
|
||||||
this._config = config;
|
this._config = config;
|
||||||
this._logger = logger;
|
|
||||||
this._server = server;
|
this._server = server;
|
||||||
this._swarm = swarm;
|
this._swarm = swarm;
|
||||||
}
|
}
|
||||||
|
@ -74,10 +71,8 @@ class PluginAPI extends EventEmitter2 {
|
||||||
throw new Error("not implemented and should not be called");
|
throw new Error("not implemented and should not be called");
|
||||||
}
|
}
|
||||||
|
|
||||||
private _logger: Logger;
|
|
||||||
|
|
||||||
get logger(): Logger {
|
get logger(): Logger {
|
||||||
return this._logger;
|
throw new Error("not implemented and should not be called");
|
||||||
}
|
}
|
||||||
|
|
||||||
get rpcServer(): RPCServer {
|
get rpcServer(): RPCServer {
|
||||||
|
@ -115,7 +110,6 @@ export function getPluginAPI(): PluginAPI {
|
||||||
if (!pluginAPI) {
|
if (!pluginAPI) {
|
||||||
pluginAPI = new PluginAPI({
|
pluginAPI = new PluginAPI({
|
||||||
config,
|
config,
|
||||||
logger: log,
|
|
||||||
server: getRpcServer(),
|
server: getRpcServer(),
|
||||||
swarm: getSwarm(),
|
swarm: getSwarm(),
|
||||||
});
|
});
|
||||||
|
@ -212,6 +206,10 @@ export class PluginAPIManager {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (prop === "logger") {
|
||||||
|
return log.child({ plugin: plugin.name });
|
||||||
|
}
|
||||||
|
|
||||||
return (target as any)[prop];
|
return (target as any)[prop];
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -71,7 +71,7 @@ export class ProtocolManager {
|
||||||
this._swarm.on("connection", (peer: any) => {
|
this._swarm.on("connection", (peer: any) => {
|
||||||
for (const protocol of this._protocols) {
|
for (const protocol of this._protocols) {
|
||||||
Protomux.from(peer).pair(
|
Protomux.from(peer).pair(
|
||||||
protocol[0],
|
{ protocol: protocol[0] },
|
||||||
this.handler.bind(this, protocol[0], peer)
|
this.handler.bind(this, protocol[0], peer)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue