chore: clean-up store protocol

This commit is contained in:
fryorcraken.eth 2022-10-28 09:33:05 +11:00
parent d6b7aee989
commit 4b1f0ef795
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
5 changed files with 16 additions and 17 deletions

View File

@ -23,7 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed
- Support for Waku Store 2.0.0-beta4.
- Support for Waku Store 2.0.0-beta3.
## [0.29.0] - 2022-09-21

View File

@ -1,7 +1,7 @@
import type { Uint8ArrayList } from "uint8arraylist";
import { v4 as uuid } from "uuid";
import * as protoV2Beta4 from "../../proto/store_v2beta4";
import * as proto from "../../proto/store";
const OneMillion = BigInt(1_000_000);
@ -17,17 +17,17 @@ export interface Params {
pageSize: number;
startTime?: Date;
endTime?: Date;
cursor?: protoV2Beta4.Index;
cursor?: proto.Index;
}
export class HistoryRPC {
private constructor(public readonly proto: protoV2Beta4.HistoryRPC) {}
private constructor(public readonly proto: proto.HistoryRPC) {}
get query(): protoV2Beta4.HistoryQuery | undefined {
get query(): proto.HistoryQuery | undefined {
return this.proto.query;
}
get response(): protoV2Beta4.HistoryResponse | undefined {
get response(): proto.HistoryResponse | undefined {
return this.proto.response;
}
@ -45,7 +45,7 @@ export class HistoryRPC {
pageSize: BigInt(params.pageSize),
cursor: params.cursor,
direction,
} as protoV2Beta4.PagingInfo;
} as proto.PagingInfo;
let startTime, endTime;
if (params.startTime) {
@ -71,24 +71,24 @@ export class HistoryRPC {
}
decode(bytes: Uint8ArrayList): HistoryRPC {
const res = protoV2Beta4.HistoryRPC.decode(bytes);
const res = proto.HistoryRPC.decode(bytes);
return new HistoryRPC(res);
}
encode(): Uint8Array {
return protoV2Beta4.HistoryRPC.encode(this.proto);
return proto.HistoryRPC.encode(this.proto);
}
}
function directionToProto(
pageDirection: PageDirection
): protoV2Beta4.PagingInfo.Direction {
): proto.PagingInfo.Direction {
switch (pageDirection) {
case PageDirection.BACKWARD:
return protoV2Beta4.PagingInfo.Direction.DIRECTION_BACKWARD_UNSPECIFIED;
return proto.PagingInfo.Direction.DIRECTION_BACKWARD_UNSPECIFIED;
case PageDirection.FORWARD:
return protoV2Beta4.PagingInfo.Direction.DIRECTION_FORWARD;
return proto.PagingInfo.Direction.DIRECTION_FORWARD;
default:
return protoV2Beta4.PagingInfo.Direction.DIRECTION_BACKWARD_UNSPECIFIED;
return proto.PagingInfo.Direction.DIRECTION_BACKWARD_UNSPECIFIED;
}
}

View File

@ -8,8 +8,7 @@ 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 * as proto from "../../proto/store";
import { DefaultPubSubTopic } from "../constants";
import { Decoder, Message } from "../interfaces";
import { selectConnection } from "../select_connection";
@ -18,7 +17,7 @@ import { toProtoMessage } from "../to_proto_message";
import { HistoryRPC, PageDirection, Params } from "./history_rpc";
import HistoryError = HistoryResponse.HistoryError;
import HistoryError = proto.HistoryResponse.HistoryError;
const log = debug("waku:store");
@ -316,7 +315,7 @@ async function* paginate<T extends Message>(
break;
}
const response = reply.response as protoV2Beta4.HistoryResponse;
const response = reply.response as proto.HistoryResponse;
if (
response.error &&