*switch to b4a

This commit is contained in:
Derrick Hammer 2022-11-24 01:49:15 -05:00
parent 587739334a
commit 734a3640e3
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 4 additions and 4 deletions

View File

@ -56,7 +56,7 @@ export default class DHTCache extends EventEmitter {
this.flood.on("message", (message, id) => this.onGetBroadcast(message, id));
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()]
@ -247,12 +247,12 @@ export default class DHTCache extends EventEmitter {
}
} else if (type === Type.CONNECTED) {
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._recalculate();
} else if (type === Type.DISCONNECTED) {
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._recalculate();
} else if (type === Type.BOOTSTRAP_REQUEST) {
@ -365,7 +365,7 @@ export default class DHTCache extends EventEmitter {
.filter(
(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 };
}