Skip to content

Commit

Permalink
Merge pull request #38 from marcuspuchalla/bugfix/#37-add-default-tra…
Browse files Browse the repository at this point in the history
…ckers

fix: Add defaul trackers and remove hardcoded trackers for discovery
  • Loading branch information
fabianbormann authored Mar 28, 2023
2 parents 6ea39a8 + b1f54de commit 5ff469a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/DAppPeerConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class DAppPeerConnect {
protected onApiEject?: (name: string, address: string) => void;
protected onApiInject?: (name: string, address: string) => void;

protected setUpDiscoveryMeerkcat = (address?: string) => {
protected setUpDiscoveryMeerkcat = (announce: Array<string>, address?: string) => {
if (address || AutoConnectHelper.getWalletDiscoveryAddress()) {
this.meerkat.logger.debug(
'DApp: create discovery with address',
Expand All @@ -45,12 +45,7 @@ export default class DAppPeerConnect {

this.walletDiscoveryMeerkat = new Meerkat({
seed: AutoConnectHelper.getWalletAutoDiscoverySeed() ?? undefined,
announce: [
'https://pro.passwordchaos.gimbalabs.io',
'wss://tracker.files.fm:7073/announce',
'wss://tracker.btorrent.xyz',
'wss://tracker.openwebtorrent.com:443/announce',
],
announce: announce,
loggingEnabled: this.enableLogging,
identifier: address ?? AutoConnectHelper.getWalletDiscoveryAddress()!,
}).setMaxListeners(20);
Expand Down Expand Up @@ -113,6 +108,7 @@ export default class DAppPeerConnect {
constructor({
dAppInfo,
seed,
discoverySeed,
announce,
loggingEnabled,
verifyConnection,
Expand All @@ -128,6 +124,15 @@ export default class DAppPeerConnect {
this.enableLogging = loggingEnabled;
}

if(!announce) {
announce = [
'https://pro.passwordchaos.gimbalabs.io',
'wss://tracker.files.fm:7073/announce',
'wss://tracker.btorrent.xyz',
'wss://tracker.openwebtorrent.com:443/announce',
]
}

this.meerkat = new Meerkat({
seed: seed || localStorage.getItem('meerkat-dapp-seed') || undefined,
announce: announce,
Expand All @@ -144,7 +149,7 @@ export default class DAppPeerConnect {
if (useWalletDiscovery) {
setTimeout(() => {
//initialize discovery meerkat 1 second later
this.setUpDiscoveryMeerkcat();
this.setUpDiscoveryMeerkcat(announce!, discoverySeed);
}, 1000);
}

Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export interface IWalletInfo {
export interface DAppPeerConnectParameters {
dAppInfo: IDAppInfos;
seed?: string;
discoverySeed?: string;
announce?: Array<string>;
loggingEnabled?: boolean;
verifyConnection?: (
Expand Down

0 comments on commit 5ff469a

Please sign in to comment.