*Ensure we use Protomux pair for the RPC service
This commit is contained in:
parent
a003da1606
commit
556373c5bc
|
@ -7,16 +7,24 @@ import { errorExit } from "../lib/error.js";
|
|||
import stringify from "json-stable-stringify";
|
||||
import {
|
||||
getRpcServer,
|
||||
RPC_PROTOCOL_ID,
|
||||
RPC_PROTOCOL_SYMBOL,
|
||||
setupStream,
|
||||
} from "./rpc/server.js";
|
||||
import { get as getSwarm, SecretStream } from "./swarm.js";
|
||||
import b4a from "b4a";
|
||||
// @ts-ignore
|
||||
import Protomux from "protomux";
|
||||
|
||||
export async function start() {
|
||||
getSwarm().on("connection", (stream: SecretStream) =>
|
||||
getRpcServer().setup(stream)
|
||||
getSwarm().on("connection", (stream: SecretStream) => {
|
||||
Protomux.from(stream).pair(
|
||||
{ protocol: "protomux-rpc", id: RPC_PROTOCOL_ID },
|
||||
async () => {
|
||||
getRpcServer().setup(stream);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
export async function getRpcByPeer(peer: Buffer | string) {
|
||||
|
|
|
@ -23,7 +23,7 @@ import config from "../../config";
|
|||
const sodium = require("sodium-universal");
|
||||
let server: RPCServer;
|
||||
|
||||
const RPC_PROTOCOL_ID = b4a.from("lumeweb");
|
||||
export const RPC_PROTOCOL_ID = b4a.from("lumeweb");
|
||||
export const RPC_PROTOCOL_SYMBOL = Symbol.for(RPC_PROTOCOL_ID.toString());
|
||||
|
||||
export function getRpcServer(): RPCServer {
|
||||
|
|
Loading…
Reference in New Issue