refactor: 重构trustlog-sdk目录结构到trustlog/go-trustlog

- 将所有trustlog-sdk文件移动到trustlog/go-trustlog/目录
- 更新README中所有import路径从trustlog-sdk改为go-trustlog
- 更新cookiecutter配置文件中的项目名称
- 更新根目录.lefthook.yml以引用新位置的配置
- 添加go.sum文件到版本控制
- 删除过时的示例文件

这次重构与trustlog-server保持一致的目录结构,
为未来支持多语言SDK(Python、Java等)预留空间。
This commit is contained in:
ryan
2025-12-22 13:37:57 +08:00
commit d313449c5c
87 changed files with 20622 additions and 0 deletions

489
api/grpc/pb/record.pb.go Normal file
View File

@@ -0,0 +1,489 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.10
// protoc v3.21.12
// source: record.proto
package pb
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// ======================== 公共数据结构 ========================
type RecordData struct {
state protoimpl.MessageState `protogen:"open.v1"`
// 记录核心信息
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // 记录唯一标识符(必填)
DoPrefix string `protobuf:"bytes,2,opt,name=do_prefix,json=doPrefix,proto3" json:"do_prefix,omitempty"` // 数据前缀标识符
ProducerId string `protobuf:"bytes,3,opt,name=producer_id,json=producerId,proto3" json:"producer_id,omitempty"` // 生产者ID
Timestamp *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // 记录时间戳
Operator string `protobuf:"bytes,5,opt,name=operator,proto3" json:"operator,omitempty"` // 操作执行者标识
Extra []byte `protobuf:"bytes,6,opt,name=extra,proto3" json:"extra,omitempty"` // 额外数据字段
RcType string `protobuf:"bytes,7,opt,name=rc_type,json=rcType,proto3" json:"rc_type,omitempty"` // 记录类型
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *RecordData) Reset() {
*x = RecordData{}
mi := &file_record_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *RecordData) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RecordData) ProtoMessage() {}
func (x *RecordData) ProtoReflect() protoreflect.Message {
mi := &file_record_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RecordData.ProtoReflect.Descriptor instead.
func (*RecordData) Descriptor() ([]byte, []int) {
return file_record_proto_rawDescGZIP(), []int{0}
}
func (x *RecordData) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *RecordData) GetDoPrefix() string {
if x != nil {
return x.DoPrefix
}
return ""
}
func (x *RecordData) GetProducerId() string {
if x != nil {
return x.ProducerId
}
return ""
}
func (x *RecordData) GetTimestamp() *timestamppb.Timestamp {
if x != nil {
return x.Timestamp
}
return nil
}
func (x *RecordData) GetOperator() string {
if x != nil {
return x.Operator
}
return ""
}
func (x *RecordData) GetExtra() []byte {
if x != nil {
return x.Extra
}
return nil
}
func (x *RecordData) GetRcType() string {
if x != nil {
return x.RcType
}
return ""
}
// ======================== 列表查询请求 & 返回 ========================
type ListRecordReq struct {
state protoimpl.MessageState `protogen:"open.v1"`
// 分页条件
PageSize uint64 `protobuf:"varint,1,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` // 页面大小
PreTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=pre_time,json=preTime,proto3" json:"pre_time,omitempty"` // 上一页最后一个时间
// 可选过滤条件
DoPrefix string `protobuf:"bytes,3,opt,name=do_prefix,json=doPrefix,proto3" json:"do_prefix,omitempty"` // 数据前缀过滤
RcType string `protobuf:"bytes,4,opt,name=rc_type,json=rcType,proto3" json:"rc_type,omitempty"` // 记录类型过滤
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ListRecordReq) Reset() {
*x = ListRecordReq{}
mi := &file_record_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ListRecordReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListRecordReq) ProtoMessage() {}
func (x *ListRecordReq) ProtoReflect() protoreflect.Message {
mi := &file_record_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListRecordReq.ProtoReflect.Descriptor instead.
func (*ListRecordReq) Descriptor() ([]byte, []int) {
return file_record_proto_rawDescGZIP(), []int{1}
}
func (x *ListRecordReq) GetPageSize() uint64 {
if x != nil {
return x.PageSize
}
return 0
}
func (x *ListRecordReq) GetPreTime() *timestamppb.Timestamp {
if x != nil {
return x.PreTime
}
return nil
}
func (x *ListRecordReq) GetDoPrefix() string {
if x != nil {
return x.DoPrefix
}
return ""
}
func (x *ListRecordReq) GetRcType() string {
if x != nil {
return x.RcType
}
return ""
}
type ListRecordRes struct {
state protoimpl.MessageState `protogen:"open.v1"`
Count int64 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"` // 数据总量
Data []*RecordData `protobuf:"bytes,2,rep,name=data,proto3" json:"data,omitempty"` // 记录数据列表
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ListRecordRes) Reset() {
*x = ListRecordRes{}
mi := &file_record_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ListRecordRes) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListRecordRes) ProtoMessage() {}
func (x *ListRecordRes) ProtoReflect() protoreflect.Message {
mi := &file_record_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListRecordRes.ProtoReflect.Descriptor instead.
func (*ListRecordRes) Descriptor() ([]byte, []int) {
return file_record_proto_rawDescGZIP(), []int{2}
}
func (x *ListRecordRes) GetCount() int64 {
if x != nil {
return x.Count
}
return 0
}
func (x *ListRecordRes) GetData() []*RecordData {
if x != nil {
return x.Data
}
return nil
}
// ======================== 记录验证请求 & 流式响应 ========================
type RecordValidationReq struct {
state protoimpl.MessageState `protogen:"open.v1"`
Timestamp *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // 记录时间戳
RecordId string `protobuf:"bytes,2,opt,name=record_id,json=recordId,proto3" json:"record_id,omitempty"` // 要验证的记录ID
DoPrefix string `protobuf:"bytes,3,opt,name=do_prefix,json=doPrefix,proto3" json:"do_prefix,omitempty"` // 数据前缀(可选)
RcType string `protobuf:"bytes,4,opt,name=rc_type,json=rcType,proto3" json:"rc_type,omitempty"` // 记录类型
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *RecordValidationReq) Reset() {
*x = RecordValidationReq{}
mi := &file_record_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *RecordValidationReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RecordValidationReq) ProtoMessage() {}
func (x *RecordValidationReq) ProtoReflect() protoreflect.Message {
mi := &file_record_proto_msgTypes[3]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RecordValidationReq.ProtoReflect.Descriptor instead.
func (*RecordValidationReq) Descriptor() ([]byte, []int) {
return file_record_proto_rawDescGZIP(), []int{3}
}
func (x *RecordValidationReq) GetTimestamp() *timestamppb.Timestamp {
if x != nil {
return x.Timestamp
}
return nil
}
func (x *RecordValidationReq) GetRecordId() string {
if x != nil {
return x.RecordId
}
return ""
}
func (x *RecordValidationReq) GetDoPrefix() string {
if x != nil {
return x.DoPrefix
}
return ""
}
func (x *RecordValidationReq) GetRcType() string {
if x != nil {
return x.RcType
}
return ""
}
type RecordValidationStreamRes struct {
state protoimpl.MessageState `protogen:"open.v1"`
Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` // 状态码100处理中200完成400客户端错误500服务器错误
Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"` // 消息描述
Progress string `protobuf:"bytes,3,opt,name=progress,proto3" json:"progress,omitempty"` // 验证进度(如 "30%", "验证哈希完成"
// 验证结果详情(仅在完成时返回)
Result *RecordData `protobuf:"bytes,4,opt,name=result,proto3" json:"result,omitempty"`
Proof *Proof `protobuf:"bytes,5,opt,name=proof,proto3" json:"proof,omitempty"` // 取证证明(仅在完成时返回)
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *RecordValidationStreamRes) Reset() {
*x = RecordValidationStreamRes{}
mi := &file_record_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *RecordValidationStreamRes) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RecordValidationStreamRes) ProtoMessage() {}
func (x *RecordValidationStreamRes) ProtoReflect() protoreflect.Message {
mi := &file_record_proto_msgTypes[4]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RecordValidationStreamRes.ProtoReflect.Descriptor instead.
func (*RecordValidationStreamRes) Descriptor() ([]byte, []int) {
return file_record_proto_rawDescGZIP(), []int{4}
}
func (x *RecordValidationStreamRes) GetCode() int32 {
if x != nil {
return x.Code
}
return 0
}
func (x *RecordValidationStreamRes) GetMsg() string {
if x != nil {
return x.Msg
}
return ""
}
func (x *RecordValidationStreamRes) GetProgress() string {
if x != nil {
return x.Progress
}
return ""
}
func (x *RecordValidationStreamRes) GetResult() *RecordData {
if x != nil {
return x.Result
}
return nil
}
func (x *RecordValidationStreamRes) GetProof() *Proof {
if x != nil {
return x.Proof
}
return nil
}
var File_record_proto protoreflect.FileDescriptor
const file_record_proto_rawDesc = "" +
"\n" +
"\frecord.proto\x12\x06record\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\fcommon.proto\"\xdf\x01\n" +
"\n" +
"RecordData\x12\x0e\n" +
"\x02id\x18\x01 \x01(\tR\x02id\x12\x1b\n" +
"\tdo_prefix\x18\x02 \x01(\tR\bdoPrefix\x12\x1f\n" +
"\vproducer_id\x18\x03 \x01(\tR\n" +
"producerId\x128\n" +
"\ttimestamp\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampR\ttimestamp\x12\x1a\n" +
"\boperator\x18\x05 \x01(\tR\boperator\x12\x14\n" +
"\x05extra\x18\x06 \x01(\fR\x05extra\x12\x17\n" +
"\arc_type\x18\a \x01(\tR\x06rcType\"\x99\x01\n" +
"\rListRecordReq\x12\x1b\n" +
"\tpage_size\x18\x01 \x01(\x04R\bpageSize\x125\n" +
"\bpre_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\apreTime\x12\x1b\n" +
"\tdo_prefix\x18\x03 \x01(\tR\bdoPrefix\x12\x17\n" +
"\arc_type\x18\x04 \x01(\tR\x06rcType\"M\n" +
"\rListRecordRes\x12\x14\n" +
"\x05count\x18\x01 \x01(\x03R\x05count\x12&\n" +
"\x04data\x18\x02 \x03(\v2\x12.record.RecordDataR\x04data\"\xa2\x01\n" +
"\x13RecordValidationReq\x128\n" +
"\ttimestamp\x18\x01 \x01(\v2\x1a.google.protobuf.TimestampR\ttimestamp\x12\x1b\n" +
"\trecord_id\x18\x02 \x01(\tR\brecordId\x12\x1b\n" +
"\tdo_prefix\x18\x03 \x01(\tR\bdoPrefix\x12\x17\n" +
"\arc_type\x18\x04 \x01(\tR\x06rcType\"\xae\x01\n" +
"\x19RecordValidationStreamRes\x12\x12\n" +
"\x04code\x18\x01 \x01(\x05R\x04code\x12\x10\n" +
"\x03msg\x18\x02 \x01(\tR\x03msg\x12\x1a\n" +
"\bprogress\x18\x03 \x01(\tR\bprogress\x12*\n" +
"\x06result\x18\x04 \x01(\v2\x12.record.RecordDataR\x06result\x12#\n" +
"\x05proof\x18\x05 \x01(\v2\r.common.ProofR\x05proof2\xaa\x01\n" +
"\x17RecordValidationService\x12;\n" +
"\vListRecords\x12\x15.record.ListRecordReq\x1a\x15.record.ListRecordRes\x12R\n" +
"\x0eValidateRecord\x12\x1b.record.RecordValidationReq\x1a!.record.RecordValidationStreamRes0\x01B4Z2go.yandata.net/iod/iod/trustlog-sdk/api/grpc/pb;pbb\x06proto3"
var (
file_record_proto_rawDescOnce sync.Once
file_record_proto_rawDescData []byte
)
func file_record_proto_rawDescGZIP() []byte {
file_record_proto_rawDescOnce.Do(func() {
file_record_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_record_proto_rawDesc), len(file_record_proto_rawDesc)))
})
return file_record_proto_rawDescData
}
var file_record_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
var file_record_proto_goTypes = []any{
(*RecordData)(nil), // 0: record.RecordData
(*ListRecordReq)(nil), // 1: record.ListRecordReq
(*ListRecordRes)(nil), // 2: record.ListRecordRes
(*RecordValidationReq)(nil), // 3: record.RecordValidationReq
(*RecordValidationStreamRes)(nil), // 4: record.RecordValidationStreamRes
(*timestamppb.Timestamp)(nil), // 5: google.protobuf.Timestamp
(*Proof)(nil), // 6: common.Proof
}
var file_record_proto_depIdxs = []int32{
5, // 0: record.RecordData.timestamp:type_name -> google.protobuf.Timestamp
5, // 1: record.ListRecordReq.pre_time:type_name -> google.protobuf.Timestamp
0, // 2: record.ListRecordRes.data:type_name -> record.RecordData
5, // 3: record.RecordValidationReq.timestamp:type_name -> google.protobuf.Timestamp
0, // 4: record.RecordValidationStreamRes.result:type_name -> record.RecordData
6, // 5: record.RecordValidationStreamRes.proof:type_name -> common.Proof
1, // 6: record.RecordValidationService.ListRecords:input_type -> record.ListRecordReq
3, // 7: record.RecordValidationService.ValidateRecord:input_type -> record.RecordValidationReq
2, // 8: record.RecordValidationService.ListRecords:output_type -> record.ListRecordRes
4, // 9: record.RecordValidationService.ValidateRecord:output_type -> record.RecordValidationStreamRes
8, // [8:10] is the sub-list for method output_type
6, // [6:8] is the sub-list for method input_type
6, // [6:6] is the sub-list for extension type_name
6, // [6:6] is the sub-list for extension extendee
0, // [0:6] is the sub-list for field type_name
}
func init() { file_record_proto_init() }
func file_record_proto_init() {
if File_record_proto != nil {
return
}
file_common_proto_init()
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_record_proto_rawDesc), len(file_record_proto_rawDesc)),
NumEnums: 0,
NumMessages: 5,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_record_proto_goTypes,
DependencyIndexes: file_record_proto_depIdxs,
MessageInfos: file_record_proto_msgTypes,
}.Build()
File_record_proto = out.File
file_record_proto_goTypes = nil
file_record_proto_depIdxs = nil
}