mirror of https://github.com/waku-org/js-waku.git
Merge pull request #240 from status-im/238-multiple-protocols
This commit is contained in:
commit
1f0569580f
|
@ -13,12 +13,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Examples (web-chat): New `/fleet` command to switch connection between Status prod and test fleets.
|
||||
- Export `generatePrivateKey` and `getPublicKey` directly from the root.
|
||||
- Usage of the encryption and signature APIs to the readme.
|
||||
- Support multiple protocol ids for Waku Relay, allowing interoperability with nim-waku v0.4 and latest master
|
||||
([#238](https://github.com/status-im/js-waku/issues/238)).
|
||||
|
||||
### Changed
|
||||
- **Breaking**: Renamed `WakuRelay.(add|delete)PrivateDecryptionKey` to `WakuRelay.(add|delete)DecryptionKey` to make it clearer that it accepts both symmetric keys and asymmetric private keys.
|
||||
|
||||
### Fix
|
||||
### Fixed
|
||||
- Align `WakuMessage` readme example with actual code behaviour.
|
||||
- Remove infinite loop when an error with Waku Store is encountered.
|
||||
|
||||
## [0.8.0] - 2021-07-15
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ export {
|
|||
PushResponse,
|
||||
} from './lib/waku_light_push';
|
||||
|
||||
export { WakuRelay, RelayCodec } from './lib/waku_relay';
|
||||
export { WakuRelay, RelayCodecs } from './lib/waku_relay';
|
||||
|
||||
export { Direction, WakuStore, StoreCodec } from './lib/waku_store';
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ import TCP from 'libp2p-tcp';
|
|||
import { makeLogFileName, NimWaku, NOISE_KEY_1 } from '../test_utils/';
|
||||
|
||||
import { Waku } from './waku';
|
||||
import { RelayCodec } from './waku_relay';
|
||||
|
||||
describe('Waku Dial', function () {
|
||||
describe('Interop: Nim', function () {
|
||||
|
@ -30,7 +29,7 @@ describe('Waku Dial', function () {
|
|||
expect(nimPeers).to.deep.equal([
|
||||
{
|
||||
multiaddr: multiAddrWithId,
|
||||
protocol: RelayCodec,
|
||||
protocol: '/vac/waku/relay/2.0.0-beta2',
|
||||
connected: true,
|
||||
},
|
||||
]);
|
||||
|
|
|
@ -16,7 +16,7 @@ import { Multiaddr, multiaddr } from 'multiaddr';
|
|||
import PeerId from 'peer-id';
|
||||
|
||||
import { WakuLightPush } from './waku_light_push';
|
||||
import { RelayCodec, WakuRelay } from './waku_relay';
|
||||
import { RelayCodecs, WakuRelay } from './waku_relay';
|
||||
import { StoreCodec, WakuStore } from './waku_store';
|
||||
|
||||
const websocketsTransportKey = Websockets.prototype[Symbol.toStringTag];
|
||||
|
@ -170,7 +170,7 @@ export class Waku {
|
|||
stream: MuxedStream;
|
||||
protocol: string;
|
||||
}> {
|
||||
return this.libp2p.dialProtocol(peer, [RelayCodec, StoreCodec]);
|
||||
return this.libp2p.dialProtocol(peer, [StoreCodec].concat(RelayCodecs));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,10 +4,13 @@ export const minute = 60 * second;
|
|||
/**
|
||||
* RelayCodec is the libp2p identifier for the waku relay protocol
|
||||
*/
|
||||
export const RelayCodec = '/vac/waku/relay/2.0.0-beta2';
|
||||
export const RelayCodecs = [
|
||||
'/vac/waku/relay/2.0.0-beta2',
|
||||
'/vac/waku/relay/2.0.0',
|
||||
];
|
||||
|
||||
/**
|
||||
* RelayDefaultTopic is the default gossipsub topic to use for waku relay
|
||||
* DefaultPubsubTopic is the default gossipsub topic to use for Waku.
|
||||
*/
|
||||
export const DefaultPubsubTopic = '/waku/2/default-waku/proto';
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import Gossipsub from 'libp2p-gossipsub';
|
||||
import { shuffle } from 'libp2p-gossipsub/src/utils';
|
||||
|
||||
import { RelayCodec } from './index';
|
||||
import { RelayCodecs } from './index';
|
||||
|
||||
/**
|
||||
* Given a topic, returns up to count peers subscribed to that topic
|
||||
|
@ -33,7 +33,7 @@ export function getRelayPeers(
|
|||
if (!peerStreams) {
|
||||
return;
|
||||
}
|
||||
if (peerStreams.protocol == RelayCodec && filter(id)) {
|
||||
if (RelayCodecs.includes(peerStreams.protocol) && filter(id)) {
|
||||
peers.push(id);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -14,7 +14,7 @@ import { delay } from '../delay';
|
|||
import { Waku } from '../waku';
|
||||
import { WakuMessage } from '../waku_message';
|
||||
|
||||
import { DefaultPubsubTopic, RelayCodec } from './index';
|
||||
import { DefaultPubsubTopic } from './index';
|
||||
|
||||
const log = debug('waku:test');
|
||||
|
||||
|
@ -72,7 +72,7 @@ describe('Waku Relay', () => {
|
|||
it('Register correct protocols', async function () {
|
||||
const protocols = Array.from(waku1.libp2p.upgrader.protocols.keys());
|
||||
|
||||
expect(protocols).to.contain(RelayCodec);
|
||||
expect(protocols).to.contain('/vac/waku/relay/2.0.0-beta2');
|
||||
expect(protocols.findIndex((value) => value.match(/sub/))).to.eq(-1);
|
||||
});
|
||||
|
||||
|
|
|
@ -21,13 +21,13 @@ import { CreateOptions } from '../waku';
|
|||
import { WakuMessage } from '../waku_message';
|
||||
|
||||
import * as constants from './constants';
|
||||
import { DefaultPubsubTopic, RelayCodec } from './constants';
|
||||
import { DefaultPubsubTopic, RelayCodecs } from './constants';
|
||||
import { getRelayPeers } from './get_relay_peers';
|
||||
import { RelayHeartbeat } from './relay_heartbeat';
|
||||
|
||||
const dbg = debug('waku:relay');
|
||||
|
||||
export { RelayCodec, DefaultPubsubTopic };
|
||||
export { RelayCodecs, DefaultPubsubTopic };
|
||||
|
||||
/**
|
||||
* See constructor libp2p-gossipsub [API](https://github.com/ChainSafe/js-libp2p-gossipsub#api).
|
||||
|
@ -93,7 +93,7 @@ export class WakuRelay extends Gossipsub {
|
|||
this.observers = {};
|
||||
this.decryptionKeys = new Set();
|
||||
|
||||
const multicodecs = [constants.RelayCodec];
|
||||
const multicodecs = constants.RelayCodecs;
|
||||
|
||||
Object.assign(this, { multicodecs });
|
||||
|
||||
|
@ -420,7 +420,7 @@ export class WakuRelay extends Gossipsub {
|
|||
if (
|
||||
!exclude.has(id) &&
|
||||
!this.direct.has(id) &&
|
||||
peerStreams.protocol == constants.RelayCodec &&
|
||||
constants.RelayCodecs.includes(peerStreams.protocol) &&
|
||||
this.score.score(id) >= this._options.scoreThresholds.gossipThreshold
|
||||
) {
|
||||
peersToGossip.push(id);
|
||||
|
|
|
@ -168,15 +168,18 @@ export class WakuStore {
|
|||
}
|
||||
} catch (err) {
|
||||
console.log('Failed to decode store reply', err);
|
||||
return null;
|
||||
}
|
||||
} catch (err) {
|
||||
console.log('Failed to send waku store query', err);
|
||||
return null;
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(
|
||||
'Failed to negotiate waku store protocol stream with peer',
|
||||
err
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue