Merge pull request #21 from ledgerwatch/stat_changes23

Generate State changes from .proto
This commit is contained in:
Alex Sharov 2021-08-07 11:59:48 +07:00 committed by GitHub
commit 565a19fa0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 159 additions and 70 deletions

View File

@ -42,3 +42,4 @@ jobs:
run: choco upgrade mingw cmake -y --no-progress
- run: go test ./...

1
go.mod
View File

@ -5,7 +5,6 @@ go 1.16
require (
github.com/VictoriaMetrics/metrics v1.17.3
github.com/c2h5oh/datasize v0.0.0-20200825124411-48ed595a09d2
github.com/go-stack/stack v1.8.0
github.com/golang/protobuf v1.5.2
github.com/google/btree v1.0.1
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d

View File

@ -507,6 +507,7 @@ type StateChange struct {
BlockHeight uint64 `protobuf:"varint,2,opt,name=blockHeight,proto3" json:"blockHeight,omitempty"`
BlockHash *types.H256 `protobuf:"bytes,3,opt,name=blockHash,proto3" json:"blockHash,omitempty"`
Changes []*AccountChange `protobuf:"bytes,4,rep,name=changes,proto3" json:"changes,omitempty"`
Txs [][]byte `protobuf:"bytes,5,rep,name=txs,proto3" json:"txs,omitempty"`
}
func (x *StateChange) Reset() {
@ -569,6 +570,68 @@ func (x *StateChange) GetChanges() []*AccountChange {
return nil
}
func (x *StateChange) GetTxs() [][]byte {
if x != nil {
return x.Txs
}
return nil
}
type StateChangeRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
WithStorage bool `protobuf:"varint,1,opt,name=withStorage,proto3" json:"withStorage,omitempty"`
WithTransactions bool `protobuf:"varint,2,opt,name=withTransactions,proto3" json:"withTransactions,omitempty"`
}
func (x *StateChangeRequest) Reset() {
*x = StateChangeRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_remote_kv_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *StateChangeRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*StateChangeRequest) ProtoMessage() {}
func (x *StateChangeRequest) ProtoReflect() protoreflect.Message {
mi := &file_remote_kv_proto_msgTypes[5]
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 StateChangeRequest.ProtoReflect.Descriptor instead.
func (*StateChangeRequest) Descriptor() ([]byte, []int) {
return file_remote_kv_proto_rawDescGZIP(), []int{5}
}
func (x *StateChangeRequest) GetWithStorage() bool {
if x != nil {
return x.WithStorage
}
return false
}
func (x *StateChangeRequest) GetWithTransactions() bool {
if x != nil {
return x.WithTransactions
}
return false
}
var File_remote_kv_proto protoreflect.FileDescriptor
var file_remote_kv_proto_rawDesc = []byte{
@ -607,7 +670,7 @@ var file_remote_kv_proto_rawDesc = []byte{
0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x18, 0x06,
0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x53, 0x74,
0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x0e, 0x73, 0x74, 0x6f,
0x72, 0x61, 0x67, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x22, 0xbc, 0x01, 0x0a, 0x0b,
0x72, 0x61, 0x67, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x22, 0xce, 0x01, 0x0a, 0x0b,
0x53, 0x74, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x2f, 0x0a, 0x09, 0x64,
0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x11,
0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f,
@ -619,41 +682,48 @@ var file_remote_kv_proto_rawDesc = []byte{
0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x12, 0x2f, 0x0a, 0x07, 0x63, 0x68, 0x61,
0x6e, 0x67, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x72, 0x65, 0x6d,
0x6f, 0x74, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x67,
0x65, 0x52, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x2a, 0xe8, 0x01, 0x0a, 0x02, 0x4f,
0x70, 0x12, 0x09, 0x0a, 0x05, 0x46, 0x49, 0x52, 0x53, 0x54, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09,
0x46, 0x49, 0x52, 0x53, 0x54, 0x5f, 0x44, 0x55, 0x50, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x53,
0x45, 0x45, 0x4b, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x45, 0x45, 0x4b, 0x5f, 0x42, 0x4f,
0x54, 0x48, 0x10, 0x03, 0x12, 0x0b, 0x0a, 0x07, 0x43, 0x55, 0x52, 0x52, 0x45, 0x4e, 0x54, 0x10,
0x04, 0x12, 0x08, 0x0a, 0x04, 0x4c, 0x41, 0x53, 0x54, 0x10, 0x06, 0x12, 0x0c, 0x0a, 0x08, 0x4c,
0x41, 0x53, 0x54, 0x5f, 0x44, 0x55, 0x50, 0x10, 0x07, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x45, 0x58,
0x54, 0x10, 0x08, 0x12, 0x0c, 0x0a, 0x08, 0x4e, 0x45, 0x58, 0x54, 0x5f, 0x44, 0x55, 0x50, 0x10,
0x09, 0x12, 0x0f, 0x0a, 0x0b, 0x4e, 0x45, 0x58, 0x54, 0x5f, 0x4e, 0x4f, 0x5f, 0x44, 0x55, 0x50,
0x10, 0x0b, 0x12, 0x08, 0x0a, 0x04, 0x50, 0x52, 0x45, 0x56, 0x10, 0x0c, 0x12, 0x0c, 0x0a, 0x08,
0x50, 0x52, 0x45, 0x56, 0x5f, 0x44, 0x55, 0x50, 0x10, 0x0d, 0x12, 0x0f, 0x0a, 0x0b, 0x50, 0x52,
0x45, 0x56, 0x5f, 0x4e, 0x4f, 0x5f, 0x44, 0x55, 0x50, 0x10, 0x0e, 0x12, 0x0e, 0x0a, 0x0a, 0x53,
0x45, 0x45, 0x4b, 0x5f, 0x45, 0x58, 0x41, 0x43, 0x54, 0x10, 0x0f, 0x12, 0x13, 0x0a, 0x0f, 0x53,
0x45, 0x45, 0x4b, 0x5f, 0x42, 0x4f, 0x54, 0x48, 0x5f, 0x45, 0x58, 0x41, 0x43, 0x54, 0x10, 0x10,
0x12, 0x08, 0x0a, 0x04, 0x4f, 0x50, 0x45, 0x4e, 0x10, 0x1e, 0x12, 0x09, 0x0a, 0x05, 0x43, 0x4c,
0x4f, 0x53, 0x45, 0x10, 0x1f, 0x2a, 0x48, 0x0a, 0x06, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12,
0x0b, 0x0a, 0x07, 0x53, 0x54, 0x4f, 0x52, 0x41, 0x47, 0x45, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06,
0x55, 0x50, 0x53, 0x45, 0x52, 0x54, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x43, 0x4f, 0x44, 0x45,
0x10, 0x02, 0x12, 0x0f, 0x0a, 0x0b, 0x55, 0x50, 0x53, 0x45, 0x52, 0x54, 0x5f, 0x43, 0x4f, 0x44,
0x45, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x04, 0x2a,
0x24, 0x0a, 0x09, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0b, 0x0a, 0x07,
0x46, 0x4f, 0x52, 0x57, 0x41, 0x52, 0x44, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x4e, 0x57,
0x49, 0x4e, 0x44, 0x10, 0x01, 0x32, 0xaa, 0x01, 0x0a, 0x02, 0x4b, 0x56, 0x12, 0x36, 0x0a, 0x07,
0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a,
0x13, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52,
0x65, 0x70, 0x6c, 0x79, 0x12, 0x26, 0x0a, 0x02, 0x54, 0x78, 0x12, 0x0e, 0x2e, 0x72, 0x65, 0x6d,
0x6f, 0x74, 0x65, 0x2e, 0x43, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x1a, 0x0c, 0x2e, 0x72, 0x65, 0x6d,
0x6f, 0x74, 0x65, 0x2e, 0x50, 0x61, 0x69, 0x72, 0x28, 0x01, 0x30, 0x01, 0x12, 0x44, 0x0a, 0x13,
0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x6e,
0x67, 0x65, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x13, 0x2e, 0x72, 0x65,
0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65,
0x30, 0x01, 0x42, 0x11, 0x5a, 0x0f, 0x2e, 0x2f, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x3b, 0x72,
0x65, 0x6d, 0x6f, 0x74, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x65, 0x52, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x78,
0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x03, 0x74, 0x78, 0x73, 0x22, 0x62, 0x0a, 0x12,
0x53, 0x74, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x77, 0x69, 0x74, 0x68, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67,
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x77, 0x69, 0x74, 0x68, 0x53, 0x74, 0x6f,
0x72, 0x61, 0x67, 0x65, 0x12, 0x2a, 0x0a, 0x10, 0x77, 0x69, 0x74, 0x68, 0x54, 0x72, 0x61, 0x6e,
0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10,
0x77, 0x69, 0x74, 0x68, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73,
0x2a, 0xe8, 0x01, 0x0a, 0x02, 0x4f, 0x70, 0x12, 0x09, 0x0a, 0x05, 0x46, 0x49, 0x52, 0x53, 0x54,
0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x49, 0x52, 0x53, 0x54, 0x5f, 0x44, 0x55, 0x50, 0x10,
0x01, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x45, 0x45, 0x4b, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x53,
0x45, 0x45, 0x4b, 0x5f, 0x42, 0x4f, 0x54, 0x48, 0x10, 0x03, 0x12, 0x0b, 0x0a, 0x07, 0x43, 0x55,
0x52, 0x52, 0x45, 0x4e, 0x54, 0x10, 0x04, 0x12, 0x08, 0x0a, 0x04, 0x4c, 0x41, 0x53, 0x54, 0x10,
0x06, 0x12, 0x0c, 0x0a, 0x08, 0x4c, 0x41, 0x53, 0x54, 0x5f, 0x44, 0x55, 0x50, 0x10, 0x07, 0x12,
0x08, 0x0a, 0x04, 0x4e, 0x45, 0x58, 0x54, 0x10, 0x08, 0x12, 0x0c, 0x0a, 0x08, 0x4e, 0x45, 0x58,
0x54, 0x5f, 0x44, 0x55, 0x50, 0x10, 0x09, 0x12, 0x0f, 0x0a, 0x0b, 0x4e, 0x45, 0x58, 0x54, 0x5f,
0x4e, 0x4f, 0x5f, 0x44, 0x55, 0x50, 0x10, 0x0b, 0x12, 0x08, 0x0a, 0x04, 0x50, 0x52, 0x45, 0x56,
0x10, 0x0c, 0x12, 0x0c, 0x0a, 0x08, 0x50, 0x52, 0x45, 0x56, 0x5f, 0x44, 0x55, 0x50, 0x10, 0x0d,
0x12, 0x0f, 0x0a, 0x0b, 0x50, 0x52, 0x45, 0x56, 0x5f, 0x4e, 0x4f, 0x5f, 0x44, 0x55, 0x50, 0x10,
0x0e, 0x12, 0x0e, 0x0a, 0x0a, 0x53, 0x45, 0x45, 0x4b, 0x5f, 0x45, 0x58, 0x41, 0x43, 0x54, 0x10,
0x0f, 0x12, 0x13, 0x0a, 0x0f, 0x53, 0x45, 0x45, 0x4b, 0x5f, 0x42, 0x4f, 0x54, 0x48, 0x5f, 0x45,
0x58, 0x41, 0x43, 0x54, 0x10, 0x10, 0x12, 0x08, 0x0a, 0x04, 0x4f, 0x50, 0x45, 0x4e, 0x10, 0x1e,
0x12, 0x09, 0x0a, 0x05, 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x10, 0x1f, 0x2a, 0x48, 0x0a, 0x06, 0x41,
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x54, 0x4f, 0x52, 0x41, 0x47, 0x45,
0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x50, 0x53, 0x45, 0x52, 0x54, 0x10, 0x01, 0x12, 0x08,
0x0a, 0x04, 0x43, 0x4f, 0x44, 0x45, 0x10, 0x02, 0x12, 0x0f, 0x0a, 0x0b, 0x55, 0x50, 0x53, 0x45,
0x52, 0x54, 0x5f, 0x43, 0x4f, 0x44, 0x45, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x44, 0x45, 0x4c,
0x45, 0x54, 0x45, 0x10, 0x04, 0x2a, 0x24, 0x0a, 0x09, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69,
0x6f, 0x6e, 0x12, 0x0b, 0x0a, 0x07, 0x46, 0x4f, 0x52, 0x57, 0x41, 0x52, 0x44, 0x10, 0x00, 0x12,
0x0a, 0x0a, 0x06, 0x55, 0x4e, 0x57, 0x49, 0x4e, 0x44, 0x10, 0x01, 0x32, 0xa7, 0x01, 0x0a, 0x02,
0x4b, 0x56, 0x12, 0x36, 0x0a, 0x07, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x2e,
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,
0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x13, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x56, 0x65,
0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x26, 0x0a, 0x02, 0x54, 0x78,
0x12, 0x0e, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x43, 0x75, 0x72, 0x73, 0x6f, 0x72,
0x1a, 0x0c, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x50, 0x61, 0x69, 0x72, 0x28, 0x01,
0x30, 0x01, 0x12, 0x41, 0x0a, 0x0c, 0x53, 0x74, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67,
0x65, 0x73, 0x12, 0x1a, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74,
0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13,
0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61,
0x6e, 0x67, 0x65, 0x30, 0x01, 0x42, 0x11, 0x5a, 0x0f, 0x2e, 0x2f, 0x72, 0x65, 0x6d, 0x6f, 0x74,
0x65, 0x3b, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -669,7 +739,7 @@ func file_remote_kv_proto_rawDescGZIP() []byte {
}
var file_remote_kv_proto_enumTypes = make([]protoimpl.EnumInfo, 3)
var file_remote_kv_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
var file_remote_kv_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_remote_kv_proto_goTypes = []interface{}{
(Op)(0), // 0: remote.Op
(Action)(0), // 1: remote.Action
@ -679,26 +749,27 @@ var file_remote_kv_proto_goTypes = []interface{}{
(*StorageChange)(nil), // 5: remote.StorageChange
(*AccountChange)(nil), // 6: remote.AccountChange
(*StateChange)(nil), // 7: remote.StateChange
(*types.H256)(nil), // 8: types.H256
(*types.H160)(nil), // 9: types.H160
(*emptypb.Empty)(nil), // 10: google.protobuf.Empty
(*types.VersionReply)(nil), // 11: types.VersionReply
(*StateChangeRequest)(nil), // 8: remote.StateChangeRequest
(*types.H256)(nil), // 9: types.H256
(*types.H160)(nil), // 10: types.H160
(*emptypb.Empty)(nil), // 11: google.protobuf.Empty
(*types.VersionReply)(nil), // 12: types.VersionReply
}
var file_remote_kv_proto_depIdxs = []int32{
0, // 0: remote.Cursor.op:type_name -> remote.Op
8, // 1: remote.StorageChange.location:type_name -> types.H256
9, // 2: remote.AccountChange.address:type_name -> types.H160
9, // 1: remote.StorageChange.location:type_name -> types.H256
10, // 2: remote.AccountChange.address:type_name -> types.H160
1, // 3: remote.AccountChange.action:type_name -> remote.Action
5, // 4: remote.AccountChange.storageChanges:type_name -> remote.StorageChange
2, // 5: remote.StateChange.direction:type_name -> remote.Direction
8, // 6: remote.StateChange.blockHash:type_name -> types.H256
9, // 6: remote.StateChange.blockHash:type_name -> types.H256
6, // 7: remote.StateChange.changes:type_name -> remote.AccountChange
10, // 8: remote.KV.Version:input_type -> google.protobuf.Empty
11, // 8: remote.KV.Version:input_type -> google.protobuf.Empty
3, // 9: remote.KV.Tx:input_type -> remote.Cursor
10, // 10: remote.KV.ReceiveStateChanges:input_type -> google.protobuf.Empty
11, // 11: remote.KV.Version:output_type -> types.VersionReply
8, // 10: remote.KV.StateChanges:input_type -> remote.StateChangeRequest
12, // 11: remote.KV.Version:output_type -> types.VersionReply
4, // 12: remote.KV.Tx:output_type -> remote.Pair
7, // 13: remote.KV.ReceiveStateChanges:output_type -> remote.StateChange
7, // 13: remote.KV.StateChanges:output_type -> remote.StateChange
11, // [11:14] is the sub-list for method output_type
8, // [8:11] is the sub-list for method input_type
8, // [8:8] is the sub-list for extension type_name
@ -772,6 +843,18 @@ func file_remote_kv_proto_init() {
return nil
}
}
file_remote_kv_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*StateChangeRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
@ -779,7 +862,7 @@ func file_remote_kv_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_remote_kv_proto_rawDesc,
NumEnums: 3,
NumMessages: 5,
NumMessages: 6,
NumExtensions: 0,
NumServices: 1,
},

View File

@ -24,7 +24,7 @@ type KVClient interface {
Version(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*types.VersionReply, error)
// Tx exposes read-only transactions for the key-value store
Tx(ctx context.Context, opts ...grpc.CallOption) (KV_TxClient, error)
ReceiveStateChanges(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (KV_ReceiveStateChangesClient, error)
StateChanges(ctx context.Context, in *StateChangeRequest, opts ...grpc.CallOption) (KV_StateChangesClient, error)
}
type kVClient struct {
@ -75,12 +75,12 @@ func (x *kVTxClient) Recv() (*Pair, error) {
return m, nil
}
func (c *kVClient) ReceiveStateChanges(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (KV_ReceiveStateChangesClient, error) {
stream, err := c.cc.NewStream(ctx, &KV_ServiceDesc.Streams[1], "/remote.KV/ReceiveStateChanges", opts...)
func (c *kVClient) StateChanges(ctx context.Context, in *StateChangeRequest, opts ...grpc.CallOption) (KV_StateChangesClient, error) {
stream, err := c.cc.NewStream(ctx, &KV_ServiceDesc.Streams[1], "/remote.KV/StateChanges", opts...)
if err != nil {
return nil, err
}
x := &kVReceiveStateChangesClient{stream}
x := &kVStateChangesClient{stream}
if err := x.ClientStream.SendMsg(in); err != nil {
return nil, err
}
@ -90,16 +90,16 @@ func (c *kVClient) ReceiveStateChanges(ctx context.Context, in *emptypb.Empty, o
return x, nil
}
type KV_ReceiveStateChangesClient interface {
type KV_StateChangesClient interface {
Recv() (*StateChange, error)
grpc.ClientStream
}
type kVReceiveStateChangesClient struct {
type kVStateChangesClient struct {
grpc.ClientStream
}
func (x *kVReceiveStateChangesClient) Recv() (*StateChange, error) {
func (x *kVStateChangesClient) Recv() (*StateChange, error) {
m := new(StateChange)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
@ -115,7 +115,7 @@ type KVServer interface {
Version(context.Context, *emptypb.Empty) (*types.VersionReply, error)
// Tx exposes read-only transactions for the key-value store
Tx(KV_TxServer) error
ReceiveStateChanges(*emptypb.Empty, KV_ReceiveStateChangesServer) error
StateChanges(*StateChangeRequest, KV_StateChangesServer) error
mustEmbedUnimplementedKVServer()
}
@ -129,8 +129,8 @@ func (UnimplementedKVServer) Version(context.Context, *emptypb.Empty) (*types.Ve
func (UnimplementedKVServer) Tx(KV_TxServer) error {
return status.Errorf(codes.Unimplemented, "method Tx not implemented")
}
func (UnimplementedKVServer) ReceiveStateChanges(*emptypb.Empty, KV_ReceiveStateChangesServer) error {
return status.Errorf(codes.Unimplemented, "method ReceiveStateChanges not implemented")
func (UnimplementedKVServer) StateChanges(*StateChangeRequest, KV_StateChangesServer) error {
return status.Errorf(codes.Unimplemented, "method StateChanges not implemented")
}
func (UnimplementedKVServer) mustEmbedUnimplementedKVServer() {}
@ -189,24 +189,24 @@ func (x *kVTxServer) Recv() (*Cursor, error) {
return m, nil
}
func _KV_ReceiveStateChanges_Handler(srv interface{}, stream grpc.ServerStream) error {
m := new(emptypb.Empty)
func _KV_StateChanges_Handler(srv interface{}, stream grpc.ServerStream) error {
m := new(StateChangeRequest)
if err := stream.RecvMsg(m); err != nil {
return err
}
return srv.(KVServer).ReceiveStateChanges(m, &kVReceiveStateChangesServer{stream})
return srv.(KVServer).StateChanges(m, &kVStateChangesServer{stream})
}
type KV_ReceiveStateChangesServer interface {
type KV_StateChangesServer interface {
Send(*StateChange) error
grpc.ServerStream
}
type kVReceiveStateChangesServer struct {
type kVStateChangesServer struct {
grpc.ServerStream
}
func (x *kVReceiveStateChangesServer) Send(m *StateChange) error {
func (x *kVStateChangesServer) Send(m *StateChange) error {
return x.ServerStream.SendMsg(m)
}
@ -230,8 +230,8 @@ var KV_ServiceDesc = grpc.ServiceDesc{
ClientStreams: true,
},
{
StreamName: "ReceiveStateChanges",
Handler: _KV_ReceiveStateChanges_Handler,
StreamName: "StateChanges",
Handler: _KV_StateChanges_Handler,
ServerStreams: true,
},
},

View File

@ -15,7 +15,7 @@ service KV {
// Tx exposes read-only transactions for the key-value store
rpc Tx(stream Cursor) returns (stream Pair);
rpc ReceiveStateChanges(google.protobuf.Empty) returns (stream StateChange);
rpc StateChanges(StateChangeRequest) returns (stream StateChange);
}
enum Op {
@ -85,4 +85,10 @@ message StateChange {
uint64 blockHeight = 2;
types.H256 blockHash = 3;
repeated AccountChange changes = 4;
}
repeated bytes txs = 5;
}
message StateChangeRequest {
bool withStorage = 1;
bool withTransactions = 2;
}