*switch to b4a
This commit is contained in:
parent
587739334a
commit
734a3640e3
|
@ -56,7 +56,7 @@ export default class DHTCache extends EventEmitter {
|
||||||
this.flood.on("message", (message, id) => this.onGetBroadcast(message, id));
|
this.flood.on("message", (message, id) => this.onGetBroadcast(message, id));
|
||||||
|
|
||||||
this.swarm.on("connection", (peer: any) =>
|
this.swarm.on("connection", (peer: any) =>
|
||||||
this.flood.send(peer, Buffer.from("hello"), 0)
|
this.flood.send(peer, b4a.from("hello"), 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
[...this.swarm.peers.values()]
|
[...this.swarm.peers.values()]
|
||||||
|
@ -247,12 +247,12 @@ export default class DHTCache extends EventEmitter {
|
||||||
}
|
}
|
||||||
} else if (type === Type.CONNECTED) {
|
} else if (type === Type.CONNECTED) {
|
||||||
const { id: toId } = decoded;
|
const { id: toId } = decoded;
|
||||||
this._addEntityConnection(id, Buffer.from(toId as Uint8Array));
|
this._addEntityConnection(id, b4a.from(toId as Uint8Array) as Buffer);
|
||||||
this.emit("peer-add-seen", id, toId);
|
this.emit("peer-add-seen", id, toId);
|
||||||
this._recalculate();
|
this._recalculate();
|
||||||
} else if (type === Type.DISCONNECTED) {
|
} else if (type === Type.DISCONNECTED) {
|
||||||
const { id: toId } = decoded;
|
const { id: toId } = decoded;
|
||||||
this._removeEntityConnection(id, Buffer.from(toId as Uint8Array));
|
this._removeEntityConnection(id, b4a.from(toId as Uint8Array) as Buffer);
|
||||||
this.emit("peer-remove-seen", id, toId);
|
this.emit("peer-remove-seen", id, toId);
|
||||||
this._recalculate();
|
this._recalculate();
|
||||||
} else if (type === Type.BOOTSTRAP_REQUEST) {
|
} else if (type === Type.BOOTSTRAP_REQUEST) {
|
||||||
|
@ -365,7 +365,7 @@ export default class DHTCache extends EventEmitter {
|
||||||
.filter(
|
.filter(
|
||||||
(item: any) => this.graph.node.get(item)?.type === EntityType.PUBKEY
|
(item: any) => this.graph.node.get(item)?.type === EntityType.PUBKEY
|
||||||
)
|
)
|
||||||
.map((id: string) => Buffer.from(id, "hex"));
|
.map((id: string) => b4a.from(id, "hex"));
|
||||||
state[id] = { connectedTo };
|
state[id] = { connectedTo };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue