-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unified wireprotocol #348
base: main
Are you sure you want to change the base?
unified wireprotocol #348
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
// import { Result } from "@adviser/cement"; | ||
import { FPEnvelopeTurnaround, FPEnvelopeType, FPStoreType } from "./fp-envelope"; | ||
import { CID } from "multiformats"; | ||
|
||
export interface FPGetCarReq { | ||
readonly cid: CID; | ||
} | ||
/* | ||
* A request to get a CAR file. | ||
* As JSON, this is: | ||
* { | ||
* "type": "get-car-req", | ||
* "tid": "123", | ||
* "payload": { | ||
* "cid": "bafybeib2v" | ||
* } | ||
* "auth": { ... } | ||
* "meta": { ... } | ||
* } | ||
*/ | ||
export interface FPEnvelopeGetCarReq extends FPCarReq<FPGetCarReq> { | ||
readonly type: FPEnvelopeType.GET_CARREQ; | ||
readonly storeType: FPStoreType.CAR; | ||
} | ||
|
||
export interface FPGetCarRes { | ||
readonly cid: CID; | ||
readonly bytes: Uint8Array; | ||
} | ||
/* | ||
* The response to a GetCar request. | ||
* As JSON, this is: | ||
* { | ||
* "type": "get-car-res", | ||
* "tid": "123", | ||
* "payload": { | ||
* "cid": "bafybeib2v" | ||
* "bytes": [0x65, 0x66, 0x67, ...], | ||
* } | ||
* "auth": { ... } | ||
* "meta": { ... } | ||
* } | ||
*/ | ||
export interface FPEnvelopeGetCarRes extends FPCarRes<FPGetCarRes> { | ||
readonly type: FPEnvelopeType.GET_CARRES; | ||
readonly storeType: FPStoreType.CAR; | ||
} | ||
|
||
export interface FPPutCarReq { | ||
readonly cid: CID; | ||
readonly bytes: Uint8Array; | ||
} | ||
/* | ||
* A request to get a CAR file. | ||
* As JSON, this is: | ||
* { | ||
* "type": "put-car-req", | ||
* "tid": "123", | ||
* "payload": { | ||
* "cid": "bafybeib2v" | ||
* "bytes": [0x65, 0x66, 0x67, ...], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the put request to the signed upload URL generator doesnt include the bytes, the bytes are sent raw on the s3 protocol on a subsequent request |
||
* } | ||
* "auth": { ... } | ||
* "meta": { ... } | ||
* } | ||
*/ | ||
export interface FPEnvelopePutCarReq extends FPCarReq<FPPutCarReq> { | ||
readonly type: FPEnvelopeType.PUT_CARREQ; | ||
readonly storeType: FPStoreType.CAR; | ||
} | ||
|
||
export interface FPDelCarReq { | ||
readonly cid: CID; | ||
} | ||
/* | ||
* The response to a PutCar request. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the signed upload url can be returned as a redirect, but today we put it in a json envelope, either is ok, but the result here should just be a URL in the s3 protocol |
||
* As JSON, this is: | ||
* { | ||
* "type": "del-car-res", | ||
* "tid": "123", | ||
* "payload": { | ||
* "cid": "bafybeib2v" | ||
* "meta": { | ||
* "key1": "value1", | ||
* } | ||
* } | ||
* "auth": { ... } | ||
* "meta": { ... } | ||
* } | ||
*/ | ||
export interface FPEnvelopeDelCarReq extends FPCarReq<FPDelCarReq> { | ||
readonly type: FPEnvelopeType.DEL_CARREQ; | ||
readonly storeType: FPStoreType.CAR; | ||
} | ||
|
||
|
||
export interface FPDelCarRes { | ||
readonly cid: CID; | ||
// optional deleted bytes | ||
readonly bytes?: Uint8Array; | ||
} | ||
/* | ||
* A request to get a CAR file. | ||
* As JSON, this is: | ||
* { | ||
* "type": "get-car-req", | ||
* "tid": "123", | ||
* "payload": { | ||
* "cid": "bafybeib2v" | ||
* "bytes": [0x65, 0x66, 0x67, ...], | ||
* } | ||
* "auth": { ... } | ||
* "meta": { ... } | ||
* } | ||
*/ | ||
export interface FPEnvelopeDelCarRes extends FPCarRes<FPDelCarRes> { | ||
readonly type: FPEnvelopeType.DEL_CARRES; | ||
readonly storeType: FPStoreType.CAR; | ||
} | ||
|
||
export interface FPCarReq<T> extends FPEnvelopeTurnaround<T> { | ||
readonly type: FPEnvelopeType.DEL_CARREQ | FPEnvelopeType.GET_CARREQ | FPEnvelopeType.PUT_CARREQ; | ||
readonly storeType: FPStoreType.CAR; | ||
} | ||
|
||
export interface FPCarRes<T> extends FPEnvelopeTurnaround<T> { | ||
readonly type: FPEnvelopeType.DEL_CARRES | FPEnvelopeType.GET_CARRES | FPEnvelopeType.PUT_CARRES; | ||
readonly storeType: FPStoreType.CAR; | ||
} | ||
|
||
// export interface FPEnvelopeCar extends FPEnvelope<Uint8Array> { | ||
// readonly type: FPEnvelopeType.CAR; | ||
// } | ||
|
||
// export function Car2FPMsg(fpcar: Uint8Array): Result<FPEnvelopeCar> { | ||
// return Result.Ok({ type: FPEnvelopeType.CAR, payload: fpcar }); | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not just send the car raw as binary? the CAR get and PUT dont need to be parsed by the server