// @generated by protobuf-ts 2.9.0 // @generated from protobuf file "signed_piece.proto" (package "pb", syntax proto3) // tslint:disable import type { BinaryWriteOptions } from "@protobuf-ts/runtime"; import type { IBinaryWriter } from "@protobuf-ts/runtime"; import { WireType } from "@protobuf-ts/runtime"; import type { BinaryReadOptions } from "@protobuf-ts/runtime"; import type { IBinaryReader } from "@protobuf-ts/runtime"; import { UnknownFieldHandler } from "@protobuf-ts/runtime"; import type { PartialMessage } from "@protobuf-ts/runtime"; import { reflectionMergePartial } from "@protobuf-ts/runtime"; import { MESSAGE_TYPE } from "@protobuf-ts/runtime"; import { MessageType } from "@protobuf-ts/runtime"; import { Signature } from "./signature"; /** * * A piece signed by an account. * This can be used to verify the intent of the account holder to upload the piece. * * @generated from protobuf message pb.SignedPiece */ export interface SignedPiece { /** * A Piece message serialized in protobuf. * * @generated from protobuf field: bytes piece = 1; */ piece: Uint8Array; /** * A signature of the piece by the keypair of the uploader. * * @generated from protobuf field: pb.Signature signature = 2; */ signature?: Signature; } // @generated message type with reflection information, may provide speed optimized methods class SignedPiece$Type extends MessageType { constructor() { super("pb.SignedPiece", [ { no: 1, name: "piece", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }, { no: 2, name: "signature", kind: "message", T: () => Signature } ]); } create(value?: PartialMessage): SignedPiece { const message = { piece: new Uint8Array(0) }; globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this }); if (value !== undefined) reflectionMergePartial(this, message, value); return message; } internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: SignedPiece): SignedPiece { let message = target ?? this.create(), end = reader.pos + length; while (reader.pos < end) { let [fieldNo, wireType] = reader.tag(); switch (fieldNo) { case /* bytes piece */ 1: message.piece = reader.bytes(); break; case /* pb.Signature signature */ 2: message.signature = Signature.internalBinaryRead(reader, reader.uint32(), options, message.signature); break; default: let u = options.readUnknownField; if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); let d = reader.skip(wireType); if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); } } return message; } internalBinaryWrite(message: SignedPiece, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { /* bytes piece = 1; */ if (message.piece.length) writer.tag(1, WireType.LengthDelimited).bytes(message.piece); /* pb.Signature signature = 2; */ if (message.signature) Signature.internalBinaryWrite(message.signature, writer.tag(2, WireType.LengthDelimited).fork(), options).join(); let u = options.writeUnknownFields; if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); return writer; } } /** * @generated MessageType for protobuf message pb.SignedPiece */ export const SignedPiece = new SignedPiece$Type();