mirror of
https://github.com/status-im/js-waku.git
synced 2025-02-23 10:28:15 +00:00
fix: it-length-prefixed now returns Uint8ArrayList
This commit is contained in:
parent
ab76063f33
commit
bfeaf6c14e
1
package-lock.json
generated
1
package-lock.json
generated
@ -34,6 +34,7 @@
|
|||||||
"libp2p": "0.38.0",
|
"libp2p": "0.38.0",
|
||||||
"p-event": "^5.0.1",
|
"p-event": "^5.0.1",
|
||||||
"protons-runtime": "^3.1.0",
|
"protons-runtime": "^3.1.0",
|
||||||
|
"uint8arraylist": "^2.3.2",
|
||||||
"uint8arrays": "^3.0.0",
|
"uint8arrays": "^3.0.0",
|
||||||
"uuid": "^8.3.2"
|
"uuid": "^8.3.2"
|
||||||
},
|
},
|
||||||
|
@ -114,6 +114,7 @@
|
|||||||
"libp2p": "0.38.0",
|
"libp2p": "0.38.0",
|
||||||
"p-event": "^5.0.1",
|
"p-event": "^5.0.1",
|
||||||
"protons-runtime": "^3.1.0",
|
"protons-runtime": "^3.1.0",
|
||||||
|
"uint8arraylist": "^2.3.2",
|
||||||
"uint8arrays": "^3.0.0",
|
"uint8arrays": "^3.0.0",
|
||||||
"uuid": "^8.3.2"
|
"uuid": "^8.3.2"
|
||||||
},
|
},
|
||||||
|
@ -4,11 +4,11 @@ import all from "it-all";
|
|||||||
import * as lp from "it-length-prefixed";
|
import * as lp from "it-length-prefixed";
|
||||||
import { pipe } from "it-pipe";
|
import { pipe } from "it-pipe";
|
||||||
import { Libp2p } from "libp2p";
|
import { Libp2p } from "libp2p";
|
||||||
|
import { Uint8ArrayList } from "uint8arraylist";
|
||||||
|
|
||||||
import { PushResponse } from "../../proto/light_push";
|
import { PushResponse } from "../../proto/light_push";
|
||||||
import { DefaultPubSubTopic } from "../constants";
|
import { DefaultPubSubTopic } from "../constants";
|
||||||
import { getPeersForProtocol, selectRandomPeer } from "../select_peer";
|
import { getPeersForProtocol, selectRandomPeer } from "../select_peer";
|
||||||
import { concat } from "../utils";
|
|
||||||
import { WakuMessage } from "../waku_message";
|
import { WakuMessage } from "../waku_message";
|
||||||
|
|
||||||
import { PushRPC } from "./push_rpc";
|
import { PushRPC } from "./push_rpc";
|
||||||
@ -76,7 +76,11 @@ export class WakuLightPush {
|
|||||||
async (source) => await all(source)
|
async (source) => await all(source)
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
const bytes = concat(res);
|
const bytes = new Uint8ArrayList();
|
||||||
|
res.forEach((chunk) => {
|
||||||
|
bytes.append(chunk);
|
||||||
|
});
|
||||||
|
|
||||||
const response = PushRPC.decode(bytes).response;
|
const response = PushRPC.decode(bytes).response;
|
||||||
|
|
||||||
if (!response) {
|
if (!response) {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import type { Uint8ArrayList } from "uint8arraylist";
|
||||||
import { v4 as uuid } from "uuid";
|
import { v4 as uuid } from "uuid";
|
||||||
|
|
||||||
import * as proto from "../../proto/light_push";
|
import * as proto from "../../proto/light_push";
|
||||||
@ -17,7 +18,7 @@ export class PushRPC {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static decode(bytes: Uint8Array): PushRPC {
|
static decode(bytes: Uint8ArrayList): PushRPC {
|
||||||
const res = proto.PushRPC.decode(bytes);
|
const res = proto.PushRPC.decode(bytes);
|
||||||
return new PushRPC(res);
|
return new PushRPC(res);
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import type { Uint8ArrayList } from "uint8arraylist";
|
||||||
import { v4 as uuid } from "uuid";
|
import { v4 as uuid } from "uuid";
|
||||||
|
|
||||||
import * as protoV2Beta3 from "../../proto/store_v2beta3";
|
import * as protoV2Beta3 from "../../proto/store_v2beta3";
|
||||||
@ -139,7 +140,7 @@ export class HistoryRPC {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
decode(bytes: Uint8Array): HistoryRPC {
|
decode(bytes: Uint8ArrayList): HistoryRPC {
|
||||||
const res = this.historyRpc.decode(bytes);
|
const res = this.historyRpc.decode(bytes);
|
||||||
return new HistoryRPC(res, this.storeCodec);
|
return new HistoryRPC(res, this.storeCodec);
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,13 @@ import all from "it-all";
|
|||||||
import * as lp from "it-length-prefixed";
|
import * as lp from "it-length-prefixed";
|
||||||
import { pipe } from "it-pipe";
|
import { pipe } from "it-pipe";
|
||||||
import { Libp2p } from "libp2p";
|
import { Libp2p } from "libp2p";
|
||||||
|
import { Uint8ArrayList } from "uint8arraylist";
|
||||||
|
|
||||||
import * as protoV2Beta4 from "../../proto/store_v2beta4";
|
import * as protoV2Beta4 from "../../proto/store_v2beta4";
|
||||||
import { HistoryResponse } from "../../proto/store_v2beta4";
|
import { HistoryResponse } from "../../proto/store_v2beta4";
|
||||||
import { DefaultPubSubTopic, StoreCodecs } from "../constants";
|
import { DefaultPubSubTopic, StoreCodecs } from "../constants";
|
||||||
import { getPeersForProtocol, selectRandomPeer } from "../select_peer";
|
import { getPeersForProtocol, selectRandomPeer } from "../select_peer";
|
||||||
import { concat, hexToBytes } from "../utils";
|
import { hexToBytes } from "../utils";
|
||||||
import { DecryptionMethod, WakuMessage } from "../waku_message";
|
import { DecryptionMethod, WakuMessage } from "../waku_message";
|
||||||
|
|
||||||
import { HistoryRPC, PageDirection } from "./history_rpc";
|
import { HistoryRPC, PageDirection } from "./history_rpc";
|
||||||
@ -211,7 +212,11 @@ export class WakuStore {
|
|||||||
lp.decode(),
|
lp.decode(),
|
||||||
async (source) => await all(source)
|
async (source) => await all(source)
|
||||||
);
|
);
|
||||||
const bytes = concat(res);
|
const bytes = new Uint8ArrayList();
|
||||||
|
res.forEach((chunk) => {
|
||||||
|
bytes.append(chunk);
|
||||||
|
});
|
||||||
|
|
||||||
const reply = historyRpcQuery.decode(bytes);
|
const reply = historyRpcQuery.decode(bytes);
|
||||||
|
|
||||||
if (!reply.response) {
|
if (!reply.response) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user