@waku/discovery 0.0.4-04bd518.0 → 0.0.4-15400a5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/index.js +195 -308
- package/dist/.tsbuildinfo +1 -1
- package/dist/dns/constants.d.ts +0 -2
- package/dist/dns/constants.js +1 -3
- package/dist/dns/constants.js.map +1 -1
- package/dist/peer-exchange/waku_peer_exchange.js +2 -2
- package/dist/peer-exchange/waku_peer_exchange.js.map +1 -1
- package/dist/peer-exchange/waku_peer_exchange_discovery.d.ts +1 -0
- package/dist/peer-exchange/waku_peer_exchange_discovery.js +47 -2
- package/dist/peer-exchange/waku_peer_exchange_discovery.js.map +1 -1
- package/package.json +1 -1
- package/src/dns/constants.ts +1 -4
- package/src/peer-exchange/waku_peer_exchange.ts +3 -2
- package/src/peer-exchange/waku_peer_exchange_discovery.ts +78 -2
package/bundle/index.js
CHANGED
@@ -537,6 +537,11 @@ var ProtocolError;
|
|
537
537
|
* Ensure that the pubsub topic used for decoder creation is the same as the one used for protocol.
|
538
538
|
*/
|
539
539
|
ProtocolError["TOPIC_DECODER_MISMATCH"] = "Topic decoder mismatch";
|
540
|
+
/**
|
541
|
+
* The topics passed in the decoders do not match each other, or don't exist at all.
|
542
|
+
* Ensure that all the pubsub topics used in the decoders are valid and match each other.
|
543
|
+
*/
|
544
|
+
ProtocolError["INVALID_DECODER_TOPICS"] = "Invalid decoder topics";
|
540
545
|
/**
|
541
546
|
* Failure to find a peer with suitable protocols. This may due to a connection issue.
|
542
547
|
* Mitigation can be: retrying after a given time period, display connectivity issue
|
@@ -567,12 +572,6 @@ var ProtocolError;
|
|
567
572
|
ProtocolError["REQUEST_TIMEOUT"] = "Request timeout";
|
568
573
|
})(ProtocolError || (ProtocolError = {}));
|
569
574
|
|
570
|
-
var PageDirection;
|
571
|
-
(function (PageDirection) {
|
572
|
-
PageDirection["BACKWARD"] = "backward";
|
573
|
-
PageDirection["FORWARD"] = "forward";
|
574
|
-
})(PageDirection || (PageDirection = {}));
|
575
|
-
|
576
575
|
var Tags;
|
577
576
|
(function (Tags) {
|
578
577
|
Tags["BOOTSTRAP"] = "bootstrap";
|
@@ -591,14 +590,18 @@ var EConnectionStateEvents;
|
|
591
590
|
EConnectionStateEvents["CONNECTION_STATUS"] = "waku:connection";
|
592
591
|
})(EConnectionStateEvents || (EConnectionStateEvents = {}));
|
593
592
|
|
594
|
-
/**
|
595
|
-
* DefaultPubsubTopic is the default gossipsub topic to use for Waku.
|
596
|
-
*/
|
597
593
|
/**
|
598
594
|
* The default cluster ID for The Waku Network
|
599
595
|
*/
|
600
596
|
const DEFAULT_CLUSTER_ID = 1;
|
601
597
|
|
598
|
+
var HealthStatus;
|
599
|
+
(function (HealthStatus) {
|
600
|
+
HealthStatus["Unhealthy"] = "Unhealthy";
|
601
|
+
HealthStatus["MinimallyHealthy"] = "MinimallyHealthy";
|
602
|
+
HealthStatus["SufficientlyHealthy"] = "SufficientlyHealthy";
|
603
|
+
})(HealthStatus || (HealthStatus = {}));
|
604
|
+
|
602
605
|
function equals$2(aa, bb) {
|
603
606
|
if (aa === bb)
|
604
607
|
return true;
|
@@ -2888,12 +2891,10 @@ let Logger$1 = class Logger {
|
|
2888
2891
|
/**
|
2889
2892
|
* The ENR tree for the different fleets.
|
2890
2893
|
* SANDBOX and TEST fleets are for The Waku Network.
|
2891
|
-
* DEPRECATED_DEFAULT_PUBSUB is the fleet of nodes supporting the now deprecated DefaultPubsubTopic.
|
2892
2894
|
*/
|
2893
2895
|
const enrTree = {
|
2894
2896
|
SANDBOX: "enrtree://AIRVQ5DDA4FFWLRBCHJWUWOO6X6S4ZTZ5B667LQ6AJU6PEYDLRD5O@sandbox.waku.nodes.status.im",
|
2895
|
-
TEST: "enrtree://AOGYWMBYOUIMOENHXCHILPKY3ZRFEULMFI4DOM442QSZ73TT2A7VI@test.waku.nodes.status.im"
|
2896
|
-
DEPRECATED_DEFAULT_PUBSUB: "enrtree://ANEDLO25QVUGJOUTQFRYKWX6P4Z4GKVESBMHML7DZ6YK4LGS5FC5O@prod.wakuv2.nodes.status.im"
|
2897
|
+
TEST: "enrtree://AOGYWMBYOUIMOENHXCHILPKY3ZRFEULMFI4DOM442QSZ73TT2A7VI@test.waku.nodes.status.im"
|
2897
2898
|
};
|
2898
2899
|
const DEFAULT_BOOTSTRAP_TAG_NAME = "bootstrap";
|
2899
2900
|
const DEFAULT_BOOTSTRAP_TAG_VALUE = 50;
|
@@ -23844,113 +23845,26 @@ var WakuMessage$1;
|
|
23844
23845
|
/* eslint-disable @typescript-eslint/no-namespace */
|
23845
23846
|
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
|
23846
23847
|
/* eslint-disable @typescript-eslint/no-empty-interface */
|
23847
|
-
var
|
23848
|
-
(function (
|
23848
|
+
var WakuMessageKeyValue;
|
23849
|
+
(function (WakuMessageKeyValue) {
|
23849
23850
|
let _codec;
|
23850
|
-
|
23851
|
+
WakuMessageKeyValue.codec = () => {
|
23851
23852
|
if (_codec == null) {
|
23852
23853
|
_codec = message((obj, w, opts = {}) => {
|
23853
23854
|
if (opts.lengthDelimited !== false) {
|
23854
23855
|
w.fork();
|
23855
23856
|
}
|
23856
|
-
if (
|
23857
|
+
if (obj.messageHash != null) {
|
23857
23858
|
w.uint32(10);
|
23858
|
-
w.bytes(obj.
|
23859
|
-
}
|
23860
|
-
if ((obj.receiverTime != null && obj.receiverTime !== 0n)) {
|
23861
|
-
w.uint32(16);
|
23862
|
-
w.sint64(obj.receiverTime);
|
23863
|
-
}
|
23864
|
-
if ((obj.senderTime != null && obj.senderTime !== 0n)) {
|
23865
|
-
w.uint32(24);
|
23866
|
-
w.sint64(obj.senderTime);
|
23867
|
-
}
|
23868
|
-
if ((obj.pubsubTopic != null && obj.pubsubTopic !== '')) {
|
23869
|
-
w.uint32(34);
|
23870
|
-
w.string(obj.pubsubTopic);
|
23871
|
-
}
|
23872
|
-
if (opts.lengthDelimited !== false) {
|
23873
|
-
w.ldelim();
|
23859
|
+
w.bytes(obj.messageHash);
|
23874
23860
|
}
|
23875
|
-
|
23876
|
-
const obj = {
|
23877
|
-
digest: alloc$2(0),
|
23878
|
-
receiverTime: 0n,
|
23879
|
-
senderTime: 0n,
|
23880
|
-
pubsubTopic: ''
|
23881
|
-
};
|
23882
|
-
const end = length == null ? reader.len : reader.pos + length;
|
23883
|
-
while (reader.pos < end) {
|
23884
|
-
const tag = reader.uint32();
|
23885
|
-
switch (tag >>> 3) {
|
23886
|
-
case 1: {
|
23887
|
-
obj.digest = reader.bytes();
|
23888
|
-
break;
|
23889
|
-
}
|
23890
|
-
case 2: {
|
23891
|
-
obj.receiverTime = reader.sint64();
|
23892
|
-
break;
|
23893
|
-
}
|
23894
|
-
case 3: {
|
23895
|
-
obj.senderTime = reader.sint64();
|
23896
|
-
break;
|
23897
|
-
}
|
23898
|
-
case 4: {
|
23899
|
-
obj.pubsubTopic = reader.string();
|
23900
|
-
break;
|
23901
|
-
}
|
23902
|
-
default: {
|
23903
|
-
reader.skipType(tag & 7);
|
23904
|
-
break;
|
23905
|
-
}
|
23906
|
-
}
|
23907
|
-
}
|
23908
|
-
return obj;
|
23909
|
-
});
|
23910
|
-
}
|
23911
|
-
return _codec;
|
23912
|
-
};
|
23913
|
-
Index.encode = (obj) => {
|
23914
|
-
return encodeMessage(obj, Index.codec());
|
23915
|
-
};
|
23916
|
-
Index.decode = (buf, opts) => {
|
23917
|
-
return decodeMessage(buf, Index.codec(), opts);
|
23918
|
-
};
|
23919
|
-
})(Index || (Index = {}));
|
23920
|
-
var PagingInfo;
|
23921
|
-
(function (PagingInfo) {
|
23922
|
-
(function (Direction) {
|
23923
|
-
Direction["BACKWARD"] = "BACKWARD";
|
23924
|
-
Direction["FORWARD"] = "FORWARD";
|
23925
|
-
})(PagingInfo.Direction || (PagingInfo.Direction = {}));
|
23926
|
-
let __DirectionValues;
|
23927
|
-
(function (__DirectionValues) {
|
23928
|
-
__DirectionValues[__DirectionValues["BACKWARD"] = 0] = "BACKWARD";
|
23929
|
-
__DirectionValues[__DirectionValues["FORWARD"] = 1] = "FORWARD";
|
23930
|
-
})(__DirectionValues || (__DirectionValues = {}));
|
23931
|
-
(function (Direction) {
|
23932
|
-
Direction.codec = () => {
|
23933
|
-
return enumeration(__DirectionValues);
|
23934
|
-
};
|
23935
|
-
})(PagingInfo.Direction || (PagingInfo.Direction = {}));
|
23936
|
-
let _codec;
|
23937
|
-
PagingInfo.codec = () => {
|
23938
|
-
if (_codec == null) {
|
23939
|
-
_codec = message((obj, w, opts = {}) => {
|
23940
|
-
if (opts.lengthDelimited !== false) {
|
23941
|
-
w.fork();
|
23942
|
-
}
|
23943
|
-
if (obj.pageSize != null) {
|
23944
|
-
w.uint32(8);
|
23945
|
-
w.uint64(obj.pageSize);
|
23946
|
-
}
|
23947
|
-
if (obj.cursor != null) {
|
23861
|
+
if (obj.message != null) {
|
23948
23862
|
w.uint32(18);
|
23949
|
-
|
23863
|
+
WakuMessage.codec().encode(obj.message, w);
|
23950
23864
|
}
|
23951
|
-
if (obj.
|
23952
|
-
w.uint32(
|
23953
|
-
|
23865
|
+
if (obj.pubsubTopic != null) {
|
23866
|
+
w.uint32(26);
|
23867
|
+
w.string(obj.pubsubTopic);
|
23954
23868
|
}
|
23955
23869
|
if (opts.lengthDelimited !== false) {
|
23956
23870
|
w.ldelim();
|
@@ -23962,17 +23876,17 @@ var PagingInfo;
|
|
23962
23876
|
const tag = reader.uint32();
|
23963
23877
|
switch (tag >>> 3) {
|
23964
23878
|
case 1: {
|
23965
|
-
obj.
|
23879
|
+
obj.messageHash = reader.bytes();
|
23966
23880
|
break;
|
23967
23881
|
}
|
23968
23882
|
case 2: {
|
23969
|
-
obj.
|
23970
|
-
limits: opts.limits?.
|
23883
|
+
obj.message = WakuMessage.codec().decode(reader, reader.uint32(), {
|
23884
|
+
limits: opts.limits?.message
|
23971
23885
|
});
|
23972
23886
|
break;
|
23973
23887
|
}
|
23974
23888
|
case 3: {
|
23975
|
-
obj.
|
23889
|
+
obj.pubsubTopic = reader.string();
|
23976
23890
|
break;
|
23977
23891
|
}
|
23978
23892
|
default: {
|
@@ -23986,217 +23900,125 @@ var PagingInfo;
|
|
23986
23900
|
}
|
23987
23901
|
return _codec;
|
23988
23902
|
};
|
23989
|
-
|
23990
|
-
return encodeMessage(obj,
|
23903
|
+
WakuMessageKeyValue.encode = (obj) => {
|
23904
|
+
return encodeMessage(obj, WakuMessageKeyValue.codec());
|
23991
23905
|
};
|
23992
|
-
|
23993
|
-
return decodeMessage(buf,
|
23906
|
+
WakuMessageKeyValue.decode = (buf, opts) => {
|
23907
|
+
return decodeMessage(buf, WakuMessageKeyValue.codec(), opts);
|
23994
23908
|
};
|
23995
|
-
})(
|
23996
|
-
var
|
23997
|
-
(function (
|
23909
|
+
})(WakuMessageKeyValue || (WakuMessageKeyValue = {}));
|
23910
|
+
var StoreQueryRequest;
|
23911
|
+
(function (StoreQueryRequest) {
|
23998
23912
|
let _codec;
|
23999
|
-
|
23913
|
+
StoreQueryRequest.codec = () => {
|
24000
23914
|
if (_codec == null) {
|
24001
23915
|
_codec = message((obj, w, opts = {}) => {
|
24002
23916
|
if (opts.lengthDelimited !== false) {
|
24003
23917
|
w.fork();
|
24004
23918
|
}
|
24005
|
-
if ((obj.
|
23919
|
+
if ((obj.requestId != null && obj.requestId !== '')) {
|
24006
23920
|
w.uint32(10);
|
24007
|
-
w.string(obj.
|
23921
|
+
w.string(obj.requestId);
|
24008
23922
|
}
|
24009
|
-
if (
|
24010
|
-
w.
|
23923
|
+
if ((obj.includeData != null && obj.includeData !== false)) {
|
23924
|
+
w.uint32(16);
|
23925
|
+
w.bool(obj.includeData);
|
24011
23926
|
}
|
24012
|
-
|
24013
|
-
|
24014
|
-
|
24015
|
-
}
|
24016
|
-
|
24017
|
-
|
24018
|
-
|
24019
|
-
|
24020
|
-
case 1: {
|
24021
|
-
obj.contentTopic = reader.string();
|
24022
|
-
break;
|
24023
|
-
}
|
24024
|
-
default: {
|
24025
|
-
reader.skipType(tag & 7);
|
24026
|
-
break;
|
24027
|
-
}
|
23927
|
+
if (obj.pubsubTopic != null) {
|
23928
|
+
w.uint32(82);
|
23929
|
+
w.string(obj.pubsubTopic);
|
23930
|
+
}
|
23931
|
+
if (obj.contentTopics != null) {
|
23932
|
+
for (const value of obj.contentTopics) {
|
23933
|
+
w.uint32(90);
|
23934
|
+
w.string(value);
|
24028
23935
|
}
|
24029
23936
|
}
|
24030
|
-
|
24031
|
-
|
24032
|
-
|
24033
|
-
return _codec;
|
24034
|
-
};
|
24035
|
-
ContentFilter.encode = (obj) => {
|
24036
|
-
return encodeMessage(obj, ContentFilter.codec());
|
24037
|
-
};
|
24038
|
-
ContentFilter.decode = (buf, opts) => {
|
24039
|
-
return decodeMessage(buf, ContentFilter.codec(), opts);
|
24040
|
-
};
|
24041
|
-
})(ContentFilter || (ContentFilter = {}));
|
24042
|
-
var HistoryQuery;
|
24043
|
-
(function (HistoryQuery) {
|
24044
|
-
let _codec;
|
24045
|
-
HistoryQuery.codec = () => {
|
24046
|
-
if (_codec == null) {
|
24047
|
-
_codec = message((obj, w, opts = {}) => {
|
24048
|
-
if (opts.lengthDelimited !== false) {
|
24049
|
-
w.fork();
|
23937
|
+
if (obj.timeStart != null) {
|
23938
|
+
w.uint32(96);
|
23939
|
+
w.sint64(obj.timeStart);
|
24050
23940
|
}
|
24051
|
-
if (obj.
|
24052
|
-
w.uint32(
|
24053
|
-
w.
|
23941
|
+
if (obj.timeEnd != null) {
|
23942
|
+
w.uint32(104);
|
23943
|
+
w.sint64(obj.timeEnd);
|
24054
23944
|
}
|
24055
|
-
if (obj.
|
24056
|
-
for (const value of obj.
|
24057
|
-
w.uint32(
|
24058
|
-
|
23945
|
+
if (obj.messageHashes != null) {
|
23946
|
+
for (const value of obj.messageHashes) {
|
23947
|
+
w.uint32(162);
|
23948
|
+
w.bytes(value);
|
24059
23949
|
}
|
24060
23950
|
}
|
24061
|
-
if (obj.
|
24062
|
-
w.uint32(
|
24063
|
-
|
23951
|
+
if (obj.paginationCursor != null) {
|
23952
|
+
w.uint32(410);
|
23953
|
+
w.bytes(obj.paginationCursor);
|
24064
23954
|
}
|
24065
|
-
if (obj.
|
24066
|
-
w.uint32(
|
24067
|
-
w.
|
23955
|
+
if ((obj.paginationForward != null && obj.paginationForward !== false)) {
|
23956
|
+
w.uint32(416);
|
23957
|
+
w.bool(obj.paginationForward);
|
24068
23958
|
}
|
24069
|
-
if (obj.
|
24070
|
-
w.uint32(
|
24071
|
-
w.
|
23959
|
+
if (obj.paginationLimit != null) {
|
23960
|
+
w.uint32(424);
|
23961
|
+
w.uint64(obj.paginationLimit);
|
24072
23962
|
}
|
24073
23963
|
if (opts.lengthDelimited !== false) {
|
24074
23964
|
w.ldelim();
|
24075
23965
|
}
|
24076
23966
|
}, (reader, length, opts = {}) => {
|
24077
23967
|
const obj = {
|
24078
|
-
|
23968
|
+
requestId: '',
|
23969
|
+
includeData: false,
|
23970
|
+
contentTopics: [],
|
23971
|
+
messageHashes: [],
|
23972
|
+
paginationForward: false
|
24079
23973
|
};
|
24080
23974
|
const end = length == null ? reader.len : reader.pos + length;
|
24081
23975
|
while (reader.pos < end) {
|
24082
23976
|
const tag = reader.uint32();
|
24083
23977
|
switch (tag >>> 3) {
|
24084
|
-
case
|
24085
|
-
obj.
|
23978
|
+
case 1: {
|
23979
|
+
obj.requestId = reader.string();
|
24086
23980
|
break;
|
24087
23981
|
}
|
24088
|
-
case
|
24089
|
-
|
24090
|
-
throw new CodeError('decode error - map field "contentFilters" had too many elements', 'ERR_MAX_LENGTH');
|
24091
|
-
}
|
24092
|
-
obj.contentFilters.push(ContentFilter.codec().decode(reader, reader.uint32(), {
|
24093
|
-
limits: opts.limits?.contentFilters$
|
24094
|
-
}));
|
23982
|
+
case 2: {
|
23983
|
+
obj.includeData = reader.bool();
|
24095
23984
|
break;
|
24096
23985
|
}
|
24097
|
-
case
|
24098
|
-
obj.
|
24099
|
-
limits: opts.limits?.pagingInfo
|
24100
|
-
});
|
23986
|
+
case 10: {
|
23987
|
+
obj.pubsubTopic = reader.string();
|
24101
23988
|
break;
|
24102
23989
|
}
|
24103
|
-
case
|
24104
|
-
obj.
|
23990
|
+
case 11: {
|
23991
|
+
if (opts.limits?.contentTopics != null && obj.contentTopics.length === opts.limits.contentTopics) {
|
23992
|
+
throw new CodeError('decode error - map field "contentTopics" had too many elements', 'ERR_MAX_LENGTH');
|
23993
|
+
}
|
23994
|
+
obj.contentTopics.push(reader.string());
|
24105
23995
|
break;
|
24106
23996
|
}
|
24107
|
-
case
|
24108
|
-
obj.
|
23997
|
+
case 12: {
|
23998
|
+
obj.timeStart = reader.sint64();
|
24109
23999
|
break;
|
24110
24000
|
}
|
24111
|
-
|
24112
|
-
reader.
|
24001
|
+
case 13: {
|
24002
|
+
obj.timeEnd = reader.sint64();
|
24113
24003
|
break;
|
24114
24004
|
}
|
24115
|
-
|
24116
|
-
|
24117
|
-
|
24118
|
-
});
|
24119
|
-
}
|
24120
|
-
return _codec;
|
24121
|
-
};
|
24122
|
-
HistoryQuery.encode = (obj) => {
|
24123
|
-
return encodeMessage(obj, HistoryQuery.codec());
|
24124
|
-
};
|
24125
|
-
HistoryQuery.decode = (buf, opts) => {
|
24126
|
-
return decodeMessage(buf, HistoryQuery.codec(), opts);
|
24127
|
-
};
|
24128
|
-
})(HistoryQuery || (HistoryQuery = {}));
|
24129
|
-
var HistoryResponse;
|
24130
|
-
(function (HistoryResponse) {
|
24131
|
-
let HistoryError;
|
24132
|
-
(function (HistoryError) {
|
24133
|
-
HistoryError["NONE"] = "NONE";
|
24134
|
-
HistoryError["INVALID_CURSOR"] = "INVALID_CURSOR";
|
24135
|
-
HistoryError["TOO_MANY_REQUESTS"] = "TOO_MANY_REQUESTS";
|
24136
|
-
HistoryError["SERVICE_UNAVAILABLE"] = "SERVICE_UNAVAILABLE";
|
24137
|
-
})(HistoryError = HistoryResponse.HistoryError || (HistoryResponse.HistoryError = {}));
|
24138
|
-
let __HistoryErrorValues;
|
24139
|
-
(function (__HistoryErrorValues) {
|
24140
|
-
__HistoryErrorValues[__HistoryErrorValues["NONE"] = 0] = "NONE";
|
24141
|
-
__HistoryErrorValues[__HistoryErrorValues["INVALID_CURSOR"] = 1] = "INVALID_CURSOR";
|
24142
|
-
__HistoryErrorValues[__HistoryErrorValues["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
|
24143
|
-
__HistoryErrorValues[__HistoryErrorValues["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
|
24144
|
-
})(__HistoryErrorValues || (__HistoryErrorValues = {}));
|
24145
|
-
(function (HistoryError) {
|
24146
|
-
HistoryError.codec = () => {
|
24147
|
-
return enumeration(__HistoryErrorValues);
|
24148
|
-
};
|
24149
|
-
})(HistoryError = HistoryResponse.HistoryError || (HistoryResponse.HistoryError = {}));
|
24150
|
-
let _codec;
|
24151
|
-
HistoryResponse.codec = () => {
|
24152
|
-
if (_codec == null) {
|
24153
|
-
_codec = message((obj, w, opts = {}) => {
|
24154
|
-
if (opts.lengthDelimited !== false) {
|
24155
|
-
w.fork();
|
24156
|
-
}
|
24157
|
-
if (obj.messages != null) {
|
24158
|
-
for (const value of obj.messages) {
|
24159
|
-
w.uint32(18);
|
24160
|
-
WakuMessage.codec().encode(value, w);
|
24161
|
-
}
|
24162
|
-
}
|
24163
|
-
if (obj.pagingInfo != null) {
|
24164
|
-
w.uint32(26);
|
24165
|
-
PagingInfo.codec().encode(obj.pagingInfo, w);
|
24166
|
-
}
|
24167
|
-
if (obj.error != null && __HistoryErrorValues[obj.error] !== 0) {
|
24168
|
-
w.uint32(32);
|
24169
|
-
HistoryResponse.HistoryError.codec().encode(obj.error, w);
|
24170
|
-
}
|
24171
|
-
if (opts.lengthDelimited !== false) {
|
24172
|
-
w.ldelim();
|
24173
|
-
}
|
24174
|
-
}, (reader, length, opts = {}) => {
|
24175
|
-
const obj = {
|
24176
|
-
messages: [],
|
24177
|
-
error: HistoryError.NONE
|
24178
|
-
};
|
24179
|
-
const end = length == null ? reader.len : reader.pos + length;
|
24180
|
-
while (reader.pos < end) {
|
24181
|
-
const tag = reader.uint32();
|
24182
|
-
switch (tag >>> 3) {
|
24183
|
-
case 2: {
|
24184
|
-
if (opts.limits?.messages != null && obj.messages.length === opts.limits.messages) {
|
24185
|
-
throw new CodeError('decode error - map field "messages" had too many elements', 'ERR_MAX_LENGTH');
|
24005
|
+
case 20: {
|
24006
|
+
if (opts.limits?.messageHashes != null && obj.messageHashes.length === opts.limits.messageHashes) {
|
24007
|
+
throw new CodeError('decode error - map field "messageHashes" had too many elements', 'ERR_MAX_LENGTH');
|
24186
24008
|
}
|
24187
|
-
obj.
|
24188
|
-
limits: opts.limits?.messages$
|
24189
|
-
}));
|
24009
|
+
obj.messageHashes.push(reader.bytes());
|
24190
24010
|
break;
|
24191
24011
|
}
|
24192
|
-
case
|
24193
|
-
obj.
|
24194
|
-
limits: opts.limits?.pagingInfo
|
24195
|
-
});
|
24012
|
+
case 51: {
|
24013
|
+
obj.paginationCursor = reader.bytes();
|
24196
24014
|
break;
|
24197
24015
|
}
|
24198
|
-
case
|
24199
|
-
obj.
|
24016
|
+
case 52: {
|
24017
|
+
obj.paginationForward = reader.bool();
|
24018
|
+
break;
|
24019
|
+
}
|
24020
|
+
case 53: {
|
24021
|
+
obj.paginationLimit = reader.uint64();
|
24200
24022
|
break;
|
24201
24023
|
}
|
24202
24024
|
default: {
|
@@ -24210,17 +24032,17 @@ var HistoryResponse;
|
|
24210
24032
|
}
|
24211
24033
|
return _codec;
|
24212
24034
|
};
|
24213
|
-
|
24214
|
-
return encodeMessage(obj,
|
24035
|
+
StoreQueryRequest.encode = (obj) => {
|
24036
|
+
return encodeMessage(obj, StoreQueryRequest.codec());
|
24215
24037
|
};
|
24216
|
-
|
24217
|
-
return decodeMessage(buf,
|
24038
|
+
StoreQueryRequest.decode = (buf, opts) => {
|
24039
|
+
return decodeMessage(buf, StoreQueryRequest.codec(), opts);
|
24218
24040
|
};
|
24219
|
-
})(
|
24220
|
-
var
|
24221
|
-
(function (
|
24041
|
+
})(StoreQueryRequest || (StoreQueryRequest = {}));
|
24042
|
+
var StoreQueryResponse;
|
24043
|
+
(function (StoreQueryResponse) {
|
24222
24044
|
let _codec;
|
24223
|
-
|
24045
|
+
StoreQueryResponse.codec = () => {
|
24224
24046
|
if (_codec == null) {
|
24225
24047
|
_codec = message((obj, w, opts = {}) => {
|
24226
24048
|
if (opts.lengthDelimited !== false) {
|
@@ -24230,20 +24052,31 @@ var HistoryRpc;
|
|
24230
24052
|
w.uint32(10);
|
24231
24053
|
w.string(obj.requestId);
|
24232
24054
|
}
|
24233
|
-
if (obj.
|
24234
|
-
w.uint32(
|
24235
|
-
|
24055
|
+
if (obj.statusCode != null) {
|
24056
|
+
w.uint32(80);
|
24057
|
+
w.uint32(obj.statusCode);
|
24236
24058
|
}
|
24237
|
-
if (obj.
|
24238
|
-
w.uint32(
|
24239
|
-
|
24059
|
+
if (obj.statusDesc != null) {
|
24060
|
+
w.uint32(90);
|
24061
|
+
w.string(obj.statusDesc);
|
24062
|
+
}
|
24063
|
+
if (obj.messages != null) {
|
24064
|
+
for (const value of obj.messages) {
|
24065
|
+
w.uint32(162);
|
24066
|
+
WakuMessageKeyValue.codec().encode(value, w);
|
24067
|
+
}
|
24068
|
+
}
|
24069
|
+
if (obj.paginationCursor != null) {
|
24070
|
+
w.uint32(410);
|
24071
|
+
w.bytes(obj.paginationCursor);
|
24240
24072
|
}
|
24241
24073
|
if (opts.lengthDelimited !== false) {
|
24242
24074
|
w.ldelim();
|
24243
24075
|
}
|
24244
24076
|
}, (reader, length, opts = {}) => {
|
24245
24077
|
const obj = {
|
24246
|
-
requestId: ''
|
24078
|
+
requestId: '',
|
24079
|
+
messages: []
|
24247
24080
|
};
|
24248
24081
|
const end = length == null ? reader.len : reader.pos + length;
|
24249
24082
|
while (reader.pos < end) {
|
@@ -24253,16 +24086,25 @@ var HistoryRpc;
|
|
24253
24086
|
obj.requestId = reader.string();
|
24254
24087
|
break;
|
24255
24088
|
}
|
24256
|
-
case
|
24257
|
-
obj.
|
24258
|
-
limits: opts.limits?.query
|
24259
|
-
});
|
24089
|
+
case 10: {
|
24090
|
+
obj.statusCode = reader.uint32();
|
24260
24091
|
break;
|
24261
24092
|
}
|
24262
|
-
case
|
24263
|
-
obj.
|
24264
|
-
|
24265
|
-
|
24093
|
+
case 11: {
|
24094
|
+
obj.statusDesc = reader.string();
|
24095
|
+
break;
|
24096
|
+
}
|
24097
|
+
case 20: {
|
24098
|
+
if (opts.limits?.messages != null && obj.messages.length === opts.limits.messages) {
|
24099
|
+
throw new CodeError('decode error - map field "messages" had too many elements', 'ERR_MAX_LENGTH');
|
24100
|
+
}
|
24101
|
+
obj.messages.push(WakuMessageKeyValue.codec().decode(reader, reader.uint32(), {
|
24102
|
+
limits: opts.limits?.messages$
|
24103
|
+
}));
|
24104
|
+
break;
|
24105
|
+
}
|
24106
|
+
case 51: {
|
24107
|
+
obj.paginationCursor = reader.bytes();
|
24266
24108
|
break;
|
24267
24109
|
}
|
24268
24110
|
default: {
|
@@ -24276,13 +24118,13 @@ var HistoryRpc;
|
|
24276
24118
|
}
|
24277
24119
|
return _codec;
|
24278
24120
|
};
|
24279
|
-
|
24280
|
-
return encodeMessage(obj,
|
24121
|
+
StoreQueryResponse.encode = (obj) => {
|
24122
|
+
return encodeMessage(obj, StoreQueryResponse.codec());
|
24281
24123
|
};
|
24282
|
-
|
24283
|
-
return decodeMessage(buf,
|
24124
|
+
StoreQueryResponse.decode = (buf, opts) => {
|
24125
|
+
return decodeMessage(buf, StoreQueryResponse.codec(), opts);
|
24284
24126
|
};
|
24285
|
-
})(
|
24127
|
+
})(StoreQueryResponse || (StoreQueryResponse = {}));
|
24286
24128
|
var RateLimitProof;
|
24287
24129
|
(function (RateLimitProof) {
|
24288
24130
|
let _codec;
|
@@ -24864,11 +24706,11 @@ class WakuPeerExchange extends BaseProtocol {
|
|
24864
24706
|
* Make a peer exchange query to a peer
|
24865
24707
|
*/
|
24866
24708
|
async query(params) {
|
24867
|
-
const { numPeers } = params;
|
24709
|
+
const { numPeers, peerId } = params;
|
24868
24710
|
const rpcQuery = PeerExchangeRPC.createRequest({
|
24869
24711
|
numPeers: BigInt(numPeers)
|
24870
24712
|
});
|
24871
|
-
const peer = await this.peerStore.get(
|
24713
|
+
const peer = await this.peerStore.get(peerId);
|
24872
24714
|
if (!peer) {
|
24873
24715
|
return {
|
24874
24716
|
peerInfos: null,
|
@@ -25024,7 +24866,31 @@ class PeerExchangeDiscovery extends TypedEventEmitter {
|
|
25024
24866
|
}
|
25025
24867
|
const hasPeer = await this.components.peerStore.has(peerId);
|
25026
24868
|
if (hasPeer) {
|
25027
|
-
|
24869
|
+
const { hasMultiaddrDiff, hasShardDiff } = await this.checkPeerInfoDiff(peerInfo, shardInfo);
|
24870
|
+
if (hasMultiaddrDiff || hasShardDiff) {
|
24871
|
+
log$1.info(`Peer ${peerId.toString()} has updated multiaddrs or shardInfo, updating`);
|
24872
|
+
if (hasMultiaddrDiff) {
|
24873
|
+
log$1.info(`Peer ${peerId.toString()} has updated multiaddrs, updating`);
|
24874
|
+
await this.components.peerStore.patch(peerId, {
|
24875
|
+
multiaddrs: peerInfo.multiaddrs
|
24876
|
+
});
|
24877
|
+
}
|
24878
|
+
if (hasShardDiff && shardInfo) {
|
24879
|
+
log$1.info(`Peer ${peerId.toString()} has updated shardInfo, updating`);
|
24880
|
+
await this.components.peerStore.merge(peerId, {
|
24881
|
+
metadata: {
|
24882
|
+
shardInfo: encodeRelayShard(shardInfo)
|
24883
|
+
}
|
24884
|
+
});
|
24885
|
+
this.dispatchEvent(new CustomEvent("peer", {
|
24886
|
+
detail: {
|
24887
|
+
id: peerId,
|
24888
|
+
multiaddrs: peerInfo.multiaddrs
|
24889
|
+
}
|
24890
|
+
}));
|
24891
|
+
}
|
24892
|
+
continue;
|
24893
|
+
}
|
25028
24894
|
}
|
25029
24895
|
// update the tags for the peer
|
25030
24896
|
await this.components.peerStore.save(peerId, {
|
@@ -25038,6 +24904,9 @@ class PeerExchangeDiscovery extends TypedEventEmitter {
|
|
25038
24904
|
metadata: {
|
25039
24905
|
shardInfo: encodeRelayShard(shardInfo)
|
25040
24906
|
}
|
24907
|
+
}),
|
24908
|
+
...(peerInfo.multiaddrs && {
|
24909
|
+
multiaddrs: peerInfo.multiaddrs
|
25041
24910
|
})
|
25042
24911
|
});
|
25043
24912
|
log$1.info(`Discovered peer: ${peerId.toString()}`);
|
@@ -25055,6 +24924,24 @@ class PeerExchangeDiscovery extends TypedEventEmitter {
|
|
25055
24924
|
this.queryingPeers.delete(peerIdStr);
|
25056
24925
|
this.queryAttempts.delete(peerIdStr);
|
25057
24926
|
}
|
24927
|
+
async checkPeerInfoDiff(peerInfo, shardInfo) {
|
24928
|
+
const { id: peerId } = peerInfo;
|
24929
|
+
const peer = await this.components.peerStore.get(peerId);
|
24930
|
+
const existingMultiaddrs = peer.addresses.map((a) => a.multiaddr.toString());
|
24931
|
+
const newMultiaddrs = peerInfo.multiaddrs.map((ma) => ma.toString());
|
24932
|
+
const hasMultiaddrDiff = existingMultiaddrs.some((ma) => !newMultiaddrs.includes(ma));
|
24933
|
+
let hasShardDiff = false;
|
24934
|
+
const existingShardInfoBytes = peer.metadata.get("shardInfo");
|
24935
|
+
if (existingShardInfoBytes) {
|
24936
|
+
const existingShardInfo = decodeRelayShard(existingShardInfoBytes);
|
24937
|
+
if (existingShardInfo || shardInfo) {
|
24938
|
+
hasShardDiff =
|
24939
|
+
existingShardInfo.clusterId !== shardInfo?.clusterId ||
|
24940
|
+
existingShardInfo.shards.some((shard) => !shardInfo?.shards.includes(shard));
|
24941
|
+
}
|
24942
|
+
}
|
24943
|
+
return { hasMultiaddrDiff, hasShardDiff };
|
24944
|
+
}
|
25058
24945
|
}
|
25059
24946
|
function wakuPeerExchangeDiscovery(pubsubTopics) {
|
25060
24947
|
return (components) => new PeerExchangeDiscovery(components, pubsubTopics);
|