Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
feature: Add wss bootstrapping nodes (#42)
Browse files Browse the repository at this point in the history
* feature: Add wss bootstrapping nodes (#42)

* bugfix: fixed loading bootstrapping nodes

Co-authored-by: cjayross <[email protected]>
  • Loading branch information
Tryptophan and cjayross authored Sep 25, 2021
1 parent ca505c9 commit 25e3445
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
WESTEGG_URL=http://localhost:3001
NEXT_PUBLIC_WESTEGG_URL=/api
NEXT_PUBLIC_WESTEGG_VERSION=v1
NEXT_PUBLIC_BOOTSTRAP_NODES=/dns4/staging.gatsby.sh/tcp/8081/wss/ipfs/12D3KooWC3FCg8mepBicz1pFxRyUzQR5rvrjDHRKFXr1cP2dfZmL,/dns4/staging.gatsby.sh/tcp/8085/wss/ipfs/QmSmFrQJFsQ312RqJQXBjQTRiUgWnubfPbCeX1g6PbJRUQ
NEXT_PUBLIC_BOOTSTRAP_NODES=/dns4/dallas-1.gatsby.video/tcp/8081/wss/ipfs/12D3KooWEdZAgcumLfsh38KauXu89dStk4tipyfVpDtNqGcHT5Vo,/dns4/dallas-1.gatsby.video/tcp/8085/wss/ipfs/QmSmFrQJFsQ312RqJQXBjQTRiUgWnubfPbCeX1g6PbJRUQ,/dns4/austin-1.gatsby.video/tcp/8081/wss/ipfs/12D3KooWAW69ztSvT8zCnoneMgqbCQ1ajtRwk2dXEXxoCPjrtehF,/dns4/austin-1.gatsby.video/tcp/8085/wss/ipfs/QmWybfyiAVDm2JBjzp7s3zUygPvciMgEpvv6z7654UMDoT
10 changes: 7 additions & 3 deletions packages/utilities/lib/ipfs/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ export function useIPFSNode(bootstrap: string[] = []): IPFSContextType {
try {
if (ipfsRef.current) return;
const ipfs = await IPFS.create(IPFS_DEFAULT_CONFIG);
bootstrap.forEach(async (addr) => await ipfs.bootstrap.add(addr));

for (const addr of bootstrap) {
await ipfs.bootstrap.add(addr);
}

const info = await ipfs.id();
console.log(`IPFS node ready at /p2p/${info.id}`);
setIPFS(ipfs);
Expand Down Expand Up @@ -90,7 +94,7 @@ export function useIPFSContent(content?: IPFSContent): IPFSContentState {

const [result, setResult] = useState<string | undefined>(undefined);
const [loading, setLoading] = useState(true);
const [cancel, setCancel] = useState<(() => void) | undefined>(undefined);
const [, setCancel] = useState<(() => void) | undefined>(undefined);

useEffect(() => {
if (!ipfs || !content) return;
Expand Down Expand Up @@ -136,7 +140,7 @@ export function useIPFSPeers(): IPFSPeersState {

const [peers, setPeers] = useState<Array<any>>([]);
const [loading, setLoading] = useState(true);
const [cancel, setCancel] = useState<(() => void) | undefined>(undefined);
const [, setCancel] = useState<(() => void) | undefined>(undefined);
const [refresh, setRefresh] = useVolatileState();

useEffect(() => {
Expand Down

0 comments on commit 25e3445

Please sign in to comment.