diff --git a/pb/sf/substreams/intern/v2/deltas.pb.go b/pb/sf/substreams/intern/v2/deltas.pb.go index 0e70134e7..8b42edf25 100644 --- a/pb/sf/substreams/intern/v2/deltas.pb.go +++ b/pb/sf/substreams/intern/v2/deltas.pb.go @@ -22,6 +22,100 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +type Operation_Type int32 + +const ( + Operation_SET Operation_Type = 0 + Operation_SET_BYTES Operation_Type = 1 + Operation_SET_IF_NOT_EXISTS Operation_Type = 2 + Operation_SET_BYTES_IF_NOT_EXISTS Operation_Type = 3 + Operation_APPEND Operation_Type = 4 + Operation_DELETE_PREFIX Operation_Type = 5 + Operation_SET_MAX_BIG_INT Operation_Type = 6 + Operation_SET_MAX_INT64 Operation_Type = 7 + Operation_SET_MAX_FLOAT64 Operation_Type = 8 + Operation_SET_MAX_BIG_DECIMAL Operation_Type = 9 + Operation_SET_MIN_BIG_INT Operation_Type = 10 + Operation_SET_MIN_INT64 Operation_Type = 11 + Operation_SET_MIN_FLOAT64 Operation_Type = 12 + Operation_SET_MIN_BIG_DECIMAL Operation_Type = 13 + Operation_SUM_BIG_INT Operation_Type = 14 + Operation_SUM_INT64 Operation_Type = 15 + Operation_SUM_FLOAT64 Operation_Type = 16 + Operation_SUM_BIG_DECIMAL Operation_Type = 17 +) + +// Enum value maps for Operation_Type. +var ( + Operation_Type_name = map[int32]string{ + 0: "SET", + 1: "SET_BYTES", + 2: "SET_IF_NOT_EXISTS", + 3: "SET_BYTES_IF_NOT_EXISTS", + 4: "APPEND", + 5: "DELETE_PREFIX", + 6: "SET_MAX_BIG_INT", + 7: "SET_MAX_INT64", + 8: "SET_MAX_FLOAT64", + 9: "SET_MAX_BIG_DECIMAL", + 10: "SET_MIN_BIG_INT", + 11: "SET_MIN_INT64", + 12: "SET_MIN_FLOAT64", + 13: "SET_MIN_BIG_DECIMAL", + 14: "SUM_BIG_INT", + 15: "SUM_INT64", + 16: "SUM_FLOAT64", + 17: "SUM_BIG_DECIMAL", + } + Operation_Type_value = map[string]int32{ + "SET": 0, + "SET_BYTES": 1, + "SET_IF_NOT_EXISTS": 2, + "SET_BYTES_IF_NOT_EXISTS": 3, + "APPEND": 4, + "DELETE_PREFIX": 5, + "SET_MAX_BIG_INT": 6, + "SET_MAX_INT64": 7, + "SET_MAX_FLOAT64": 8, + "SET_MAX_BIG_DECIMAL": 9, + "SET_MIN_BIG_INT": 10, + "SET_MIN_INT64": 11, + "SET_MIN_FLOAT64": 12, + "SET_MIN_BIG_DECIMAL": 13, + "SUM_BIG_INT": 14, + "SUM_INT64": 15, + "SUM_FLOAT64": 16, + "SUM_BIG_DECIMAL": 17, + } +) + +func (x Operation_Type) Enum() *Operation_Type { + p := new(Operation_Type) + *p = x + return p +} + +func (x Operation_Type) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Operation_Type) Descriptor() protoreflect.EnumDescriptor { + return file_sf_substreams_intern_v2_deltas_proto_enumTypes[0].Descriptor() +} + +func (Operation_Type) Type() protoreflect.EnumType { + return &file_sf_substreams_intern_v2_deltas_proto_enumTypes[0] +} + +func (x Operation_Type) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Operation_Type.Descriptor instead. +func (Operation_Type) EnumDescriptor() ([]byte, []int) { + return file_sf_substreams_intern_v2_deltas_proto_rawDescGZIP(), []int{2, 0} +} + type ModuleOutput struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -135,6 +229,132 @@ func (*ModuleOutput_MapOutput) isModuleOutput_Data() {} func (*ModuleOutput_StoreDeltas) isModuleOutput_Data() {} +type Operations struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Operations []*Operation `protobuf:"bytes,1,rep,name=operations,proto3" json:"operations,omitempty"` +} + +func (x *Operations) Reset() { + *x = Operations{} + if protoimpl.UnsafeEnabled { + mi := &file_sf_substreams_intern_v2_deltas_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Operations) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Operations) ProtoMessage() {} + +func (x *Operations) ProtoReflect() protoreflect.Message { + mi := &file_sf_substreams_intern_v2_deltas_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Operations.ProtoReflect.Descriptor instead. +func (*Operations) Descriptor() ([]byte, []int) { + return file_sf_substreams_intern_v2_deltas_proto_rawDescGZIP(), []int{1} +} + +func (x *Operations) GetOperations() []*Operation { + if x != nil { + return x.Operations + } + return nil +} + +type Operation struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Type Operation_Type `protobuf:"varint,1,opt,name=type,proto3,enum=sf.substreams.internal.v2.Operation_Type" json:"type,omitempty"` + BlockNum uint64 `protobuf:"varint,2,opt,name=blockNum,proto3" json:"blockNum,omitempty"` + Ord uint64 `protobuf:"varint,3,opt,name=ord,proto3" json:"ord,omitempty"` + Key string `protobuf:"bytes,4,opt,name=key,proto3" json:"key,omitempty"` + Value []byte `protobuf:"bytes,5,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *Operation) Reset() { + *x = Operation{} + if protoimpl.UnsafeEnabled { + mi := &file_sf_substreams_intern_v2_deltas_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Operation) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Operation) ProtoMessage() {} + +func (x *Operation) ProtoReflect() protoreflect.Message { + mi := &file_sf_substreams_intern_v2_deltas_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Operation.ProtoReflect.Descriptor instead. +func (*Operation) Descriptor() ([]byte, []int) { + return file_sf_substreams_intern_v2_deltas_proto_rawDescGZIP(), []int{2} +} + +func (x *Operation) GetType() Operation_Type { + if x != nil { + return x.Type + } + return Operation_SET +} + +func (x *Operation) GetBlockNum() uint64 { + if x != nil { + return x.BlockNum + } + return 0 +} + +func (x *Operation) GetOrd() uint64 { + if x != nil { + return x.Ord + } + return 0 +} + +func (x *Operation) GetKey() string { + if x != nil { + return x.Key + } + return "" +} + +func (x *Operation) GetValue() []byte { + if x != nil { + return x.Value + } + return nil +} + var File_sf_substreams_intern_v2_deltas_proto protoreflect.FileDescriptor var file_sf_substreams_intern_v2_deltas_proto_rawDesc = []byte{ @@ -162,13 +382,51 @@ var file_sf_substreams_intern_v2_deltas_proto_rawDesc = []byte{ 0x61, 0x74, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x12, 0x64, 0x65, 0x62, 0x75, 0x67, 0x4c, 0x6f, 0x67, 0x73, 0x54, 0x72, 0x75, 0x6e, 0x63, 0x61, 0x74, 0x65, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x61, 0x63, 0x68, 0x65, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, - 0x63, 0x61, 0x63, 0x68, 0x65, 0x64, 0x42, 0x06, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x4d, - 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x74, 0x72, - 0x65, 0x61, 0x6d, 0x69, 0x6e, 0x67, 0x66, 0x61, 0x73, 0x74, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x74, - 0x72, 0x65, 0x61, 0x6d, 0x73, 0x2f, 0x70, 0x62, 0x2f, 0x73, 0x66, 0x2f, 0x73, 0x75, 0x62, 0x73, - 0x74, 0x72, 0x65, 0x61, 0x6d, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x2f, 0x76, 0x32, - 0x3b, 0x70, 0x62, 0x73, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x63, 0x61, 0x63, 0x68, 0x65, 0x64, 0x42, 0x06, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x52, + 0x0a, 0x0a, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x44, 0x0a, 0x0a, + 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x24, 0x2e, 0x73, 0x66, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x73, + 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x76, 0x32, 0x2e, 0x4f, 0x70, 0x65, + 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x22, 0x86, 0x04, 0x0a, 0x09, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x3d, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x29, + 0x2e, 0x73, 0x66, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x73, 0x2e, 0x69, + 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x76, 0x32, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, + 0x1a, 0x0a, 0x08, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x08, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x12, 0x10, 0x0a, 0x03, 0x6f, + 0x72, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x6f, 0x72, 0x64, 0x12, 0x10, 0x0a, + 0x03, 0x6b, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, + 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xe3, 0x02, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x07, + 0x0a, 0x03, 0x53, 0x45, 0x54, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x45, 0x54, 0x5f, 0x42, + 0x59, 0x54, 0x45, 0x53, 0x10, 0x01, 0x12, 0x15, 0x0a, 0x11, 0x53, 0x45, 0x54, 0x5f, 0x49, 0x46, + 0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x45, 0x58, 0x49, 0x53, 0x54, 0x53, 0x10, 0x02, 0x12, 0x1b, 0x0a, + 0x17, 0x53, 0x45, 0x54, 0x5f, 0x42, 0x59, 0x54, 0x45, 0x53, 0x5f, 0x49, 0x46, 0x5f, 0x4e, 0x4f, + 0x54, 0x5f, 0x45, 0x58, 0x49, 0x53, 0x54, 0x53, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x41, 0x50, + 0x50, 0x45, 0x4e, 0x44, 0x10, 0x04, 0x12, 0x11, 0x0a, 0x0d, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, + 0x5f, 0x50, 0x52, 0x45, 0x46, 0x49, 0x58, 0x10, 0x05, 0x12, 0x13, 0x0a, 0x0f, 0x53, 0x45, 0x54, + 0x5f, 0x4d, 0x41, 0x58, 0x5f, 0x42, 0x49, 0x47, 0x5f, 0x49, 0x4e, 0x54, 0x10, 0x06, 0x12, 0x11, + 0x0a, 0x0d, 0x53, 0x45, 0x54, 0x5f, 0x4d, 0x41, 0x58, 0x5f, 0x49, 0x4e, 0x54, 0x36, 0x34, 0x10, + 0x07, 0x12, 0x13, 0x0a, 0x0f, 0x53, 0x45, 0x54, 0x5f, 0x4d, 0x41, 0x58, 0x5f, 0x46, 0x4c, 0x4f, + 0x41, 0x54, 0x36, 0x34, 0x10, 0x08, 0x12, 0x17, 0x0a, 0x13, 0x53, 0x45, 0x54, 0x5f, 0x4d, 0x41, + 0x58, 0x5f, 0x42, 0x49, 0x47, 0x5f, 0x44, 0x45, 0x43, 0x49, 0x4d, 0x41, 0x4c, 0x10, 0x09, 0x12, + 0x13, 0x0a, 0x0f, 0x53, 0x45, 0x54, 0x5f, 0x4d, 0x49, 0x4e, 0x5f, 0x42, 0x49, 0x47, 0x5f, 0x49, + 0x4e, 0x54, 0x10, 0x0a, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x45, 0x54, 0x5f, 0x4d, 0x49, 0x4e, 0x5f, + 0x49, 0x4e, 0x54, 0x36, 0x34, 0x10, 0x0b, 0x12, 0x13, 0x0a, 0x0f, 0x53, 0x45, 0x54, 0x5f, 0x4d, + 0x49, 0x4e, 0x5f, 0x46, 0x4c, 0x4f, 0x41, 0x54, 0x36, 0x34, 0x10, 0x0c, 0x12, 0x17, 0x0a, 0x13, + 0x53, 0x45, 0x54, 0x5f, 0x4d, 0x49, 0x4e, 0x5f, 0x42, 0x49, 0x47, 0x5f, 0x44, 0x45, 0x43, 0x49, + 0x4d, 0x41, 0x4c, 0x10, 0x0d, 0x12, 0x0f, 0x0a, 0x0b, 0x53, 0x55, 0x4d, 0x5f, 0x42, 0x49, 0x47, + 0x5f, 0x49, 0x4e, 0x54, 0x10, 0x0e, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x55, 0x4d, 0x5f, 0x49, 0x4e, + 0x54, 0x36, 0x34, 0x10, 0x0f, 0x12, 0x0f, 0x0a, 0x0b, 0x53, 0x55, 0x4d, 0x5f, 0x46, 0x4c, 0x4f, + 0x41, 0x54, 0x36, 0x34, 0x10, 0x10, 0x12, 0x13, 0x0a, 0x0f, 0x53, 0x55, 0x4d, 0x5f, 0x42, 0x49, + 0x47, 0x5f, 0x44, 0x45, 0x43, 0x49, 0x4d, 0x41, 0x4c, 0x10, 0x11, 0x42, 0x4d, 0x5a, 0x4b, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, + 0x69, 0x6e, 0x67, 0x66, 0x61, 0x73, 0x74, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x74, 0x72, 0x65, 0x61, + 0x6d, 0x73, 0x2f, 0x70, 0x62, 0x2f, 0x73, 0x66, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x74, 0x72, 0x65, + 0x61, 0x6d, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x2f, 0x76, 0x32, 0x3b, 0x70, 0x62, + 0x73, 0x73, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -183,20 +441,26 @@ func file_sf_substreams_intern_v2_deltas_proto_rawDescGZIP() []byte { return file_sf_substreams_intern_v2_deltas_proto_rawDescData } -var file_sf_substreams_intern_v2_deltas_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_sf_substreams_intern_v2_deltas_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_sf_substreams_intern_v2_deltas_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_sf_substreams_intern_v2_deltas_proto_goTypes = []interface{}{ - (*ModuleOutput)(nil), // 0: sf.substreams.internal.v2.ModuleOutput - (*anypb.Any)(nil), // 1: google.protobuf.Any - (*v1.StoreDeltas)(nil), // 2: sf.substreams.v1.StoreDeltas + (Operation_Type)(0), // 0: sf.substreams.internal.v2.Operation.Type + (*ModuleOutput)(nil), // 1: sf.substreams.internal.v2.ModuleOutput + (*Operations)(nil), // 2: sf.substreams.internal.v2.Operations + (*Operation)(nil), // 3: sf.substreams.internal.v2.Operation + (*anypb.Any)(nil), // 4: google.protobuf.Any + (*v1.StoreDeltas)(nil), // 5: sf.substreams.v1.StoreDeltas } var file_sf_substreams_intern_v2_deltas_proto_depIdxs = []int32{ - 1, // 0: sf.substreams.internal.v2.ModuleOutput.map_output:type_name -> google.protobuf.Any - 2, // 1: sf.substreams.internal.v2.ModuleOutput.store_deltas:type_name -> sf.substreams.v1.StoreDeltas - 2, // [2:2] is the sub-list for method output_type - 2, // [2:2] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 4, // 0: sf.substreams.internal.v2.ModuleOutput.map_output:type_name -> google.protobuf.Any + 5, // 1: sf.substreams.internal.v2.ModuleOutput.store_deltas:type_name -> sf.substreams.v1.StoreDeltas + 3, // 2: sf.substreams.internal.v2.Operations.operations:type_name -> sf.substreams.internal.v2.Operation + 0, // 3: sf.substreams.internal.v2.Operation.type:type_name -> sf.substreams.internal.v2.Operation.Type + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_sf_substreams_intern_v2_deltas_proto_init() } @@ -217,6 +481,30 @@ func file_sf_substreams_intern_v2_deltas_proto_init() { return nil } } + file_sf_substreams_intern_v2_deltas_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Operations); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_sf_substreams_intern_v2_deltas_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Operation); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } file_sf_substreams_intern_v2_deltas_proto_msgTypes[0].OneofWrappers = []interface{}{ (*ModuleOutput_MapOutput)(nil), @@ -227,13 +515,14 @@ func file_sf_substreams_intern_v2_deltas_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_sf_substreams_intern_v2_deltas_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, + NumEnums: 1, + NumMessages: 3, NumExtensions: 0, NumServices: 0, }, GoTypes: file_sf_substreams_intern_v2_deltas_proto_goTypes, DependencyIndexes: file_sf_substreams_intern_v2_deltas_proto_depIdxs, + EnumInfos: file_sf_substreams_intern_v2_deltas_proto_enumTypes, MessageInfos: file_sf_substreams_intern_v2_deltas_proto_msgTypes, }.Build() File_sf_substreams_intern_v2_deltas_proto = out.File diff --git a/proto/sf/substreams/intern/v2/deltas.proto b/proto/sf/substreams/intern/v2/deltas.proto index 14a314ea3..08dd19640 100644 --- a/proto/sf/substreams/intern/v2/deltas.proto +++ b/proto/sf/substreams/intern/v2/deltas.proto @@ -17,3 +17,37 @@ message ModuleOutput { bool debug_logs_truncated = 5; bool cached = 6; } + +message Operations { + repeated Operation operations = 1; +} + +message Operation { + enum Type { + SET = 0; + SET_BYTES = 1; + SET_IF_NOT_EXISTS = 2; + SET_BYTES_IF_NOT_EXISTS = 3; + APPEND = 4; + DELETE_PREFIX = 5; + SET_MAX_BIG_INT = 6; + SET_MAX_INT64 = 7; + SET_MAX_FLOAT64 = 8; + SET_MAX_BIG_DECIMAL = 9; + SET_MIN_BIG_INT = 10; + SET_MIN_INT64 = 11; + SET_MIN_FLOAT64 = 12; + SET_MIN_BIG_DECIMAL = 13; + SUM_BIG_INT = 14; + SUM_INT64 = 15; + SUM_FLOAT64 = 16; + SUM_BIG_DECIMAL = 17; + } + + Type type = 1; + uint64 blockNum = 2; + uint64 ord = 3; + string key = 4; + bytes value = 5; + +} diff --git a/storage/store/stateops/cachingstore.go b/storage/store/stateops/cachingstore.go new file mode 100644 index 000000000..096e926b3 --- /dev/null +++ b/storage/store/stateops/cachingstore.go @@ -0,0 +1,145 @@ +package stateops + +import ( + "bytes" + "context" + "fmt" + "math/big" + + "github.com/shopspring/decimal" + "github.com/streamingfast/dstore" + "github.com/streamingfast/substreams/block" + pbssinternal "github.com/streamingfast/substreams/pb/sf/substreams/intern/v2" + "github.com/streamingfast/substreams/storage/store" + "go.uber.org/zap" + "google.golang.org/protobuf/proto" +) + +func NewConfig(name string, moduleHash string, objStore dstore.Store, moduleInitialBlock uint64, logger *zap.Logger) (*Config, error) { + substore, err := objStore.SubStore(fmt.Sprintf("%s/ops", moduleHash)) + if err != nil { + return nil, fmt.Errorf("unable to create substore for module %q: %w", moduleHash, err) + } + return &Config{ + name: name, + moduleHash: moduleHash, + objStore: substore, + moduleInitialBlock: moduleInitialBlock, + logger: logger, + }, nil +} + +type Config struct { + name string + moduleHash string + objStore dstore.Store + moduleInitialBlock uint64 + logger *zap.Logger +} + +//func (c *Config) ReadFile(ctx context.Context, inrange *block.Range) (*File, error) { +// +// file := c.NewFile(inrange) +// if err := file.Load(ctx); err != nil { +// return nil, err +// } +// return file, nil +//} + +func (c *Config) WriteFile(ctx context.Context, targetRange *block.Range, ops pbssinternal.Operations) error { + data, err := proto.Marshal(&ops) + if err != nil { + return fmt.Errorf("marshalling store operations while saving: %w", err) + } + + return c.objStore.WriteObject(ctx, c.Filename(targetRange), bytes.NewReader(data)) +} + +func (c *Config) Filename(targetRange *block.Range) string { + return fmt.Sprintf("%010d-%010d.ops", targetRange.StartBlock, targetRange.ExclusiveEndBlock) +} + +type CachingStore struct { + ctx context.Context + baseStore store.Store + // execoutConfig *execout.Config + operations pbssinternal.Operations +} + +func (cs *CachingStore) Save(rng *block.Range) error { + + return nil + //return cs.execoutConfig.WriteFile(ctx, rng, cs.operations) +} + +func (cs *CachingStore) Set(ord uint64, key string, value string) { + cs.baseStore.Set(ord, key, value) +} + +func (cs *CachingStore) SetBytes(ord uint64, key string, value []byte) { + cs.baseStore.SetBytes(ord, key, value) +} + +func (cs *CachingStore) SetIfNotExists(ord uint64, key string, value string) { + cs.baseStore.SetIfNotExists(ord, key, value) +} + +func (cs *CachingStore) SetBytesIfNotExists(ord uint64, key string, value []byte) { + cs.baseStore.SetBytesIfNotExists(ord, key, value) +} + +func (cs *CachingStore) Append(ord uint64, key string, value []byte) error { + return cs.baseStore.Append(ord, key, value) +} + +func (cs *CachingStore) DeletePrefix(ord uint64, prefix string) { + cs.baseStore.DeletePrefix(ord, prefix) +} + +func (cs *CachingStore) SetMaxBigInt(ord uint64, key string, value *big.Int) { + cs.baseStore.SetMaxBigInt(ord, key, value) +} + +func (cs *CachingStore) SetMaxInt64(ord uint64, key string, value int64) { + cs.baseStore.SetMaxInt64(ord, key, value) +} + +func (cs *CachingStore) SetMaxFloat64(ord uint64, key string, value float64) { + cs.baseStore.SetMaxFloat64(ord, key, value) +} + +func (cs *CachingStore) SetMaxBigDecimal(ord uint64, key string, value decimal.Decimal) { + cs.baseStore.SetMaxBigDecimal(ord, key, value) +} + +func (cs *CachingStore) SetMinBigInt(ord uint64, key string, value *big.Int) { + cs.baseStore.SetMinBigInt(ord, key, value) +} + +func (cs *CachingStore) SetMinInt64(ord uint64, key string, value int64) { + cs.baseStore.SetMinInt64(ord, key, value) +} + +func (cs *CachingStore) SetMinFloat64(ord uint64, key string, value float64) { + cs.baseStore.SetMinFloat64(ord, key, value) +} + +func (cs *CachingStore) SetMinBigDecimal(ord uint64, key string, value decimal.Decimal) { + cs.baseStore.SetMinBigDecimal(ord, key, value) +} + +func (cs *CachingStore) SumBigInt(ord uint64, key string, value *big.Int) { + cs.baseStore.SumBigInt(ord, key, value) +} + +func (cs *CachingStore) SumInt64(ord uint64, key string, value int64) { + cs.baseStore.SumInt64(ord, key, value) +} + +func (cs *CachingStore) SumFloat64(ord uint64, key string, value float64) { + cs.baseStore.SumFloat64(ord, key, value) +} + +func (cs *CachingStore) SumBigDecimal(ord uint64, key string, value decimal.Decimal) { + cs.baseStore.SumBigDecimal(ord, key, value) +}