diff --git a/src/index.ts b/src/index.ts index 4cfd144..46fb16e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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 }; }