@gethashd/bytecave-browser 1.0.9 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-M2EMK4BM.js → chunk-P4WRAVTF.js} +10 -9
- package/dist/index.cjs +10 -9
- package/dist/index.js +1 -1
- package/dist/react/index.js +1 -1
- package/package.json +1 -1
- package/src/client.ts +12 -16
- package/src/provider.tsx +3 -2
|
@@ -6588,15 +6588,17 @@ Nonce: ${nonce}`;
|
|
|
6588
6588
|
const existing = this.knownPeers.get(announcement.peerId);
|
|
6589
6589
|
const peerInfo = {
|
|
6590
6590
|
peerId: announcement.peerId,
|
|
6591
|
-
publicKey: existing?.publicKey || "",
|
|
6591
|
+
publicKey: announcement.publicKey || existing?.publicKey || "",
|
|
6592
6592
|
contentTypes: announcement.contentTypes || "all",
|
|
6593
|
-
connected: this.node?.getPeers().some((p) => p.toString() === announcement.peerId) || false
|
|
6593
|
+
connected: this.node?.getPeers().some((p) => p.toString() === announcement.peerId) || false,
|
|
6594
|
+
nodeId: announcement.nodeId || existing?.nodeId,
|
|
6595
|
+
// Store all health data from announcement
|
|
6596
|
+
availableStorage: announcement.availableStorage,
|
|
6597
|
+
blobCount: announcement.blobCount,
|
|
6598
|
+
timestamp: announcement.timestamp,
|
|
6599
|
+
multiaddrs: announcement.multiaddrs,
|
|
6600
|
+
relayAddrs: announcement.relayAddrs || existing?.relayAddrs
|
|
6594
6601
|
};
|
|
6595
|
-
if (announcement.relayAddrs && announcement.relayAddrs.length > 0) {
|
|
6596
|
-
peerInfo.relayAddrs = announcement.relayAddrs;
|
|
6597
|
-
} else if (existing && existing.relayAddrs) {
|
|
6598
|
-
peerInfo.relayAddrs = existing.relayAddrs;
|
|
6599
|
-
}
|
|
6600
6602
|
this.knownPeers.set(announcement.peerId, peerInfo);
|
|
6601
6603
|
this.emit("peerAnnounce", peerInfo);
|
|
6602
6604
|
}
|
|
@@ -6729,8 +6731,7 @@ function ByteCaveProvider({
|
|
|
6729
6731
|
}
|
|
6730
6732
|
};
|
|
6731
6733
|
client.on("connectionStateChange", handleStateChange);
|
|
6732
|
-
client.on("
|
|
6733
|
-
client.on("peerDisconnect", handlePeerUpdate);
|
|
6734
|
+
client.on("peerAnnounce", handlePeerUpdate);
|
|
6734
6735
|
const hasPeers = directNodeAddrs.length > 0 || relayPeers.length > 0;
|
|
6735
6736
|
console.log("[ByteCaveProvider] Auto-connect check:", {
|
|
6736
6737
|
hasPeers,
|
package/dist/index.cjs
CHANGED
|
@@ -6641,15 +6641,17 @@ Nonce: ${nonce}`;
|
|
|
6641
6641
|
const existing = this.knownPeers.get(announcement.peerId);
|
|
6642
6642
|
const peerInfo = {
|
|
6643
6643
|
peerId: announcement.peerId,
|
|
6644
|
-
publicKey: existing?.publicKey || "",
|
|
6644
|
+
publicKey: announcement.publicKey || existing?.publicKey || "",
|
|
6645
6645
|
contentTypes: announcement.contentTypes || "all",
|
|
6646
|
-
connected: this.node?.getPeers().some((p) => p.toString() === announcement.peerId) || false
|
|
6646
|
+
connected: this.node?.getPeers().some((p) => p.toString() === announcement.peerId) || false,
|
|
6647
|
+
nodeId: announcement.nodeId || existing?.nodeId,
|
|
6648
|
+
// Store all health data from announcement
|
|
6649
|
+
availableStorage: announcement.availableStorage,
|
|
6650
|
+
blobCount: announcement.blobCount,
|
|
6651
|
+
timestamp: announcement.timestamp,
|
|
6652
|
+
multiaddrs: announcement.multiaddrs,
|
|
6653
|
+
relayAddrs: announcement.relayAddrs || existing?.relayAddrs
|
|
6647
6654
|
};
|
|
6648
|
-
if (announcement.relayAddrs && announcement.relayAddrs.length > 0) {
|
|
6649
|
-
peerInfo.relayAddrs = announcement.relayAddrs;
|
|
6650
|
-
} else if (existing && existing.relayAddrs) {
|
|
6651
|
-
peerInfo.relayAddrs = existing.relayAddrs;
|
|
6652
|
-
}
|
|
6653
6655
|
this.knownPeers.set(announcement.peerId, peerInfo);
|
|
6654
6656
|
this.emit("peerAnnounce", peerInfo);
|
|
6655
6657
|
}
|
|
@@ -6782,8 +6784,7 @@ function ByteCaveProvider({
|
|
|
6782
6784
|
}
|
|
6783
6785
|
};
|
|
6784
6786
|
client.on("connectionStateChange", handleStateChange);
|
|
6785
|
-
client.on("
|
|
6786
|
-
client.on("peerDisconnect", handlePeerUpdate);
|
|
6787
|
+
client.on("peerAnnounce", handlePeerUpdate);
|
|
6787
6788
|
const hasPeers = directNodeAddrs.length > 0 || relayPeers.length > 0;
|
|
6788
6789
|
console.log("[ByteCaveProvider] Auto-connect check:", {
|
|
6789
6790
|
hasPeers,
|
package/dist/index.js
CHANGED
package/dist/react/index.js
CHANGED
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -810,30 +810,26 @@ Nonce: ${nonce}`;
|
|
|
810
810
|
});
|
|
811
811
|
}
|
|
812
812
|
|
|
813
|
-
private async handlePeerAnnouncement(announcement: {
|
|
814
|
-
peerId: string;
|
|
815
|
-
timestamp?: number;
|
|
816
|
-
relayAddrs?: string[];
|
|
817
|
-
contentTypes?: string[] | 'all';
|
|
818
|
-
}): Promise<void> {
|
|
813
|
+
private async handlePeerAnnouncement(announcement: any): Promise<void> {
|
|
819
814
|
console.log('[ByteCave] Received announcement from peer:', announcement.peerId.slice(0, 12), announcement);
|
|
820
815
|
|
|
821
816
|
const existing = this.knownPeers.get(announcement.peerId);
|
|
822
817
|
|
|
823
|
-
|
|
818
|
+
// Store ALL announcement data, not just PeerInfo fields
|
|
819
|
+
const peerInfo: any = {
|
|
824
820
|
peerId: announcement.peerId,
|
|
825
|
-
publicKey: existing?.publicKey || '',
|
|
821
|
+
publicKey: announcement.publicKey || existing?.publicKey || '',
|
|
826
822
|
contentTypes: announcement.contentTypes || 'all',
|
|
827
|
-
connected: this.node?.getPeers().some(p => p.toString() === announcement.peerId) || false
|
|
823
|
+
connected: this.node?.getPeers().some(p => p.toString() === announcement.peerId) || false,
|
|
824
|
+
nodeId: announcement.nodeId || existing?.nodeId,
|
|
825
|
+
// Store all health data from announcement
|
|
826
|
+
availableStorage: announcement.availableStorage,
|
|
827
|
+
blobCount: announcement.blobCount,
|
|
828
|
+
timestamp: announcement.timestamp,
|
|
829
|
+
multiaddrs: announcement.multiaddrs,
|
|
830
|
+
relayAddrs: announcement.relayAddrs || (existing as any)?.relayAddrs
|
|
828
831
|
};
|
|
829
832
|
|
|
830
|
-
// Preserve relay addresses from existing peer info if new announcement doesn't have them
|
|
831
|
-
if (announcement.relayAddrs && announcement.relayAddrs.length > 0) {
|
|
832
|
-
(peerInfo as any).relayAddrs = announcement.relayAddrs;
|
|
833
|
-
} else if (existing && (existing as any).relayAddrs) {
|
|
834
|
-
(peerInfo as any).relayAddrs = (existing as any).relayAddrs;
|
|
835
|
-
}
|
|
836
|
-
|
|
837
833
|
this.knownPeers.set(announcement.peerId, peerInfo);
|
|
838
834
|
|
|
839
835
|
this.emit('peerAnnounce', peerInfo);
|
package/src/provider.tsx
CHANGED
|
@@ -141,8 +141,9 @@ export function ByteCaveProvider({
|
|
|
141
141
|
};
|
|
142
142
|
|
|
143
143
|
client.on('connectionStateChange', handleStateChange);
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
// Only listen to peerAnnounce - floodsub announcements are the single source of truth
|
|
145
|
+
// They include all health data (nodeId, storage, blobs, etc.)
|
|
146
|
+
client.on('peerAnnounce', handlePeerUpdate);
|
|
146
147
|
|
|
147
148
|
const hasPeers = directNodeAddrs.length > 0 || relayPeers.length > 0;
|
|
148
149
|
|