mirror of
https://github.com/status-im/js-waku.git
synced 2025-02-21 17:38:14 +00:00
Must pass filter.all to connect to ip4 ws peer
This commit is contained in:
parent
3285d498c7
commit
09fa8a0447
@ -3,12 +3,15 @@ import Mplex from 'libp2p-mplex';
|
|||||||
import { bytes } from 'libp2p-noise/dist/src/@types/basic';
|
import { bytes } from 'libp2p-noise/dist/src/@types/basic';
|
||||||
import { Noise } from 'libp2p-noise/dist/src/noise';
|
import { Noise } from 'libp2p-noise/dist/src/noise';
|
||||||
import Websockets from 'libp2p-websockets';
|
import Websockets from 'libp2p-websockets';
|
||||||
|
import filters from 'libp2p-websockets/src/filters';
|
||||||
import { Multiaddr } from 'multiaddr';
|
import { Multiaddr } from 'multiaddr';
|
||||||
import PeerId from 'peer-id';
|
import PeerId from 'peer-id';
|
||||||
|
|
||||||
import { RelayCodec, WakuRelay } from './waku_relay';
|
import { RelayCodec, WakuRelay } from './waku_relay';
|
||||||
import { StoreCodec, WakuStore } from './waku_store';
|
import { StoreCodec, WakuStore } from './waku_store';
|
||||||
|
|
||||||
|
const transportKey = Websockets.prototype[Symbol.toStringTag];
|
||||||
|
|
||||||
export interface CreateOptions {
|
export interface CreateOptions {
|
||||||
listenAddresses: string[];
|
listenAddresses: string[];
|
||||||
staticNoiseKey: bytes | undefined;
|
staticNoiseKey: bytes | undefined;
|
||||||
@ -70,6 +73,13 @@ export default class Waku {
|
|||||||
// @ts-ignore: Type needs update
|
// @ts-ignore: Type needs update
|
||||||
pubsub: WakuRelay,
|
pubsub: WakuRelay,
|
||||||
},
|
},
|
||||||
|
config: {
|
||||||
|
transport: {
|
||||||
|
[transportKey]: {
|
||||||
|
filter: filters.all,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const wakuStore = new WakuStore(libp2p);
|
const wakuStore = new WakuStore(libp2p);
|
||||||
|
1
src/types/types.d.ts
vendored
1
src/types/types.d.ts
vendored
@ -14,3 +14,4 @@ declare module 'libp2p-secio' {
|
|||||||
export = Secio;
|
export = Secio;
|
||||||
}
|
}
|
||||||
declare module 'libp2p-websockets';
|
declare module 'libp2p-websockets';
|
||||||
|
declare module 'libp2p-websockets/src/filters';
|
||||||
|
@ -12,15 +12,12 @@ import { WakuContext } from './WakuContext';
|
|||||||
|
|
||||||
export const ChatContentTopic = 'dingpu';
|
export const ChatContentTopic = 'dingpu';
|
||||||
|
|
||||||
interface Props {
|
|
||||||
}
|
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
messages: string[],
|
messages: string[],
|
||||||
waku?: Waku
|
waku?: Waku
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function App () {
|
export default function App() {
|
||||||
let [state, setState] = useState<State>({ messages: [] });
|
let [state, setState] = useState<State>({ messages: [] });
|
||||||
|
|
||||||
|
|
||||||
@ -44,12 +41,9 @@ export default function App () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
waku.libp2p.peerStore.addressBook.add(
|
||||||
await waku.dial('/ip4/127.0.0.1/tcp/7777/ws/p2p/QmUJKveCpfwA4cY1zRybMEt5z64FRtMHLFFQwndWrSfMmf');
|
PeerId.createFromB58String('QmbEnEniueE2Cetej6UkYAtvHuXuare4fSEeyvm43kdmfq'),
|
||||||
console.log('Remote node dialed');
|
[multiaddr('/ip4/127.0.0.1/tcp/7777/ws')]);
|
||||||
} catch (e) {
|
|
||||||
console.log('Error when dialing peer ', e);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Issue starting waku ', e);
|
console.log('Issue starting waku ', e);
|
||||||
}
|
}
|
||||||
@ -61,7 +55,7 @@ export default function App () {
|
|||||||
.then(() => console.log('Waku init done'))
|
.then(() => console.log('Waku init done'))
|
||||||
.catch((e) => console.log('Waku init failed ', e));
|
.catch((e) => console.log('Waku init failed ', e));
|
||||||
}
|
}
|
||||||
}, [state.waku]);
|
});
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user