Skip to content

Commit

Permalink
Create PeerManager.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Aug 4, 2024
1 parent f2deff6 commit ff6b1dc
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Swarm } from 'warm-js';
import { CID } from 'ultiformats/cid';

class PeerManager {
async connectToPeers() {
const swarm = new Swarm({
bootstrap: [
'/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59b...gU1ZjYZcYW3dwt',
'/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMG...UtfsmvsqQLuvuJ',
],
});
await swarm.connect();
}

async disconnectFromPeers() {
const swarm = new Swarm({
bootstrap: [
'/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59b...gU1ZjYZcYW3dwt',
'/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMG...UtfsmvsqQLuvuJ',
],
});
await swarm.disconnect();
}
}

export default PeerManager;

0 comments on commit ff6b1dc

Please sign in to comment.