Must pass filter.all to connect to ip4 ws peer

This commit is contained in:
Franck Royer 2021-04-22 10:39:05 +10:00
parent 3285d498c7
commit 09fa8a0447
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
3 changed files with 16 additions and 11 deletions

View File

@ -3,12 +3,15 @@ import Mplex from 'libp2p-mplex';
import { bytes } from 'libp2p-noise/dist/src/@types/basic';
import { Noise } from 'libp2p-noise/dist/src/noise';
import Websockets from 'libp2p-websockets';
import filters from 'libp2p-websockets/src/filters';
import { Multiaddr } from 'multiaddr';
import PeerId from 'peer-id';
import { RelayCodec, WakuRelay } from './waku_relay';
import { StoreCodec, WakuStore } from './waku_store';
const transportKey = Websockets.prototype[Symbol.toStringTag];
export interface CreateOptions {
listenAddresses: string[];
staticNoiseKey: bytes | undefined;
@ -70,6 +73,13 @@ export default class Waku {
// @ts-ignore: Type needs update
pubsub: WakuRelay,
},
config: {
transport: {
[transportKey]: {
filter: filters.all,
},
},
},
});
const wakuStore = new WakuStore(libp2p);

View File

@ -14,3 +14,4 @@ declare module 'libp2p-secio' {
export = Secio;
}
declare module 'libp2p-websockets';
declare module 'libp2p-websockets/src/filters';

View File

@ -12,15 +12,12 @@ import { WakuContext } from './WakuContext';
export const ChatContentTopic = 'dingpu';
interface Props {
}
interface State {
messages: string[],
waku?: Waku
}
export default function App () {
export default function App() {
let [state, setState] = useState<State>({ messages: [] });
@ -44,12 +41,9 @@ export default function App () {
}
});
try {
await waku.dial('/ip4/127.0.0.1/tcp/7777/ws/p2p/QmUJKveCpfwA4cY1zRybMEt5z64FRtMHLFFQwndWrSfMmf');
console.log('Remote node dialed');
} catch (e) {
console.log('Error when dialing peer ', e);
}
waku.libp2p.peerStore.addressBook.add(
PeerId.createFromB58String('QmbEnEniueE2Cetej6UkYAtvHuXuare4fSEeyvm43kdmfq'),
[multiaddr('/ip4/127.0.0.1/tcp/7777/ws')]);
} catch (e) {
console.log('Issue starting waku ', e);
}
@ -61,7 +55,7 @@ export default function App () {
.then(() => console.log('Waku init done'))
.catch((e) => console.log('Waku init failed ', e));
}
}, [state.waku]);
});
return (