mirror of
https://github.com/waku-org/js-waku.git
synced 2025-01-13 05:54:54 +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",
|
||||
"p-event": "^5.0.1",
|
||||
"protons-runtime": "^3.1.0",
|
||||
"uint8arraylist": "^2.3.2",
|
||||
"uint8arrays": "^3.0.0",
|
||||
"uuid": "^8.3.2"
|
||||
},
|
||||
|
@ -114,6 +114,7 @@
|
||||
"libp2p": "0.38.0",
|
||||
"p-event": "^5.0.1",
|
||||
"protons-runtime": "^3.1.0",
|
||||
"uint8arraylist": "^2.3.2",
|
||||
"uint8arrays": "^3.0.0",
|
||||
"uuid": "^8.3.2"
|
||||
},
|
||||
|
@ -4,11 +4,11 @@ import all from "it-all";
|
||||
import * as lp from "it-length-prefixed";
|
||||
import { pipe } from "it-pipe";
|
||||
import { Libp2p } from "libp2p";
|
||||
import { Uint8ArrayList } from "uint8arraylist";
|
||||
|
||||
import { PushResponse } from "../../proto/light_push";
|
||||
import { DefaultPubSubTopic } from "../constants";
|
||||
import { getPeersForProtocol, selectRandomPeer } from "../select_peer";
|
||||
import { concat } from "../utils";
|
||||
import { WakuMessage } from "../waku_message";
|
||||
|
||||
import { PushRPC } from "./push_rpc";
|
||||
@ -76,7 +76,11 @@ export class WakuLightPush {
|
||||
async (source) => await all(source)
|
||||
);
|
||||
try {
|
||||
const bytes = concat(res);
|
||||
const bytes = new Uint8ArrayList();
|
||||
res.forEach((chunk) => {
|
||||
bytes.append(chunk);
|
||||
});
|
||||
|
||||
const response = PushRPC.decode(bytes).response;
|
||||
|
||||
if (!response) {
|
||||
|
@ -1,3 +1,4 @@
|
||||
import type { Uint8ArrayList } from "uint8arraylist";
|
||||
import { v4 as uuid } from "uuid";
|
||||
|
||||
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);
|
||||
return new PushRPC(res);
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
import type { Uint8ArrayList } from "uint8arraylist";
|
||||
import { v4 as uuid } from "uuid";
|
||||
|
||||
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);
|
||||
return new HistoryRPC(res, this.storeCodec);
|
||||
}
|
||||
|
@ -5,12 +5,13 @@ import all from "it-all";
|
||||
import * as lp from "it-length-prefixed";
|
||||
import { pipe } from "it-pipe";
|
||||
import { Libp2p } from "libp2p";
|
||||
import { Uint8ArrayList } from "uint8arraylist";
|
||||
|
||||
import * as protoV2Beta4 from "../../proto/store_v2beta4";
|
||||
import { HistoryResponse } from "../../proto/store_v2beta4";
|
||||
import { DefaultPubSubTopic, StoreCodecs } from "../constants";
|
||||
import { getPeersForProtocol, selectRandomPeer } from "../select_peer";
|
||||
import { concat, hexToBytes } from "../utils";
|
||||
import { hexToBytes } from "../utils";
|
||||
import { DecryptionMethod, WakuMessage } from "../waku_message";
|
||||
|
||||
import { HistoryRPC, PageDirection } from "./history_rpc";
|
||||
@ -211,7 +212,11 @@ export class WakuStore {
|
||||
lp.decode(),
|
||||
async (source) => await all(source)
|
||||
);
|
||||
const bytes = concat(res);
|
||||
const bytes = new Uint8ArrayList();
|
||||
res.forEach((chunk) => {
|
||||
bytes.append(chunk);
|
||||
});
|
||||
|
||||
const reply = historyRpcQuery.decode(bytes);
|
||||
|
||||
if (!reply.response) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user