From b6021fdb93ae333fb3cae9fbbd9c75494112d509 Mon Sep 17 00:00:00 2001 From: Noam Berg Date: Thu, 11 Mar 2021 11:48:31 +0200 Subject: [PATCH] storage keys and size --- interfaces/primitives/protocol.proto | 12 +++++++++++ interfaces/services/management.proto | 2 ++ interfaces/services/state_storage.proto | 2 ++ types/go/primitives/protocol.mb.go | 28 +++++++++++++++++++++++++ types/go/services/management.mb.go | 14 ++++++++++++- types/go/services/state_storage.mb.go | 14 ++++++++++++- 6 files changed, 70 insertions(+), 2 deletions(-) diff --git a/interfaces/primitives/protocol.proto b/interfaces/primitives/protocol.proto index 15b4dfe4..1309f171 100644 --- a/interfaces/primitives/protocol.proto +++ b/interfaces/primitives/protocol.proto @@ -127,3 +127,15 @@ message weight { uint64 value = 1; // size 8 bytes } + +message storage_keys { + option inline_type = "uint64"; + uint64 value = 1; + // size 8 bytes +} + +message storage_size_megabyte { + option inline_type = "uint64"; + uint64 value = 1; + // size 8 bytes +} diff --git a/interfaces/services/management.proto b/interfaces/services/management.proto index 8d9e58a8..8ba2ee5a 100644 --- a/interfaces/services/management.proto +++ b/interfaces/services/management.proto @@ -48,6 +48,8 @@ message GetSubscriptionStatusInput { message GetSubscriptionStatusOutput { bool subscription_status_is_active = 1; + primitives.storage_keys subscription_max_keys = 2; + primitives.storage_size_megabyte subscription_max_size = 3; } message GetCommitteeInput { diff --git a/interfaces/services/state_storage.proto b/interfaces/services/state_storage.proto index 381d1896..bae67b10 100644 --- a/interfaces/services/state_storage.proto +++ b/interfaces/services/state_storage.proto @@ -42,6 +42,8 @@ message GetLastCommittedBlockInfoOutput { primitives.node_address block_proposer_address = 3; primitives.timestamp_seconds current_reference_time = 4; primitives.timestamp_seconds prev_reference_time = 5; + primitives.storage_keys current_num_keys = 6; + primitives.storage_size_megabyte current_size = 7; } message CommitStateDiffInput { diff --git a/types/go/primitives/protocol.mb.go b/types/go/primitives/protocol.mb.go index 94ddf824..ed0491a8 100644 --- a/types/go/primitives/protocol.mb.go +++ b/types/go/primitives/protocol.mb.go @@ -257,3 +257,31 @@ func (x Weight) Equal(y Weight) bool { func (x Weight) KeyForMap() uint64 { return uint64(x) } + +type StorageKeys uint64 + +func (x StorageKeys) String() string { + return fmt.Sprintf("%x", uint64(x)) +} + +func (x StorageKeys) Equal(y StorageKeys) bool { + return x == y +} + +func (x StorageKeys) KeyForMap() uint64 { + return uint64(x) +} + +type StorageSizeMegabyte uint64 + +func (x StorageSizeMegabyte) String() string { + return fmt.Sprintf("%x", uint64(x)) +} + +func (x StorageSizeMegabyte) Equal(y StorageSizeMegabyte) bool { + return x == y +} + +func (x StorageSizeMegabyte) KeyForMap() uint64 { + return uint64(x) +} diff --git a/types/go/services/management.mb.go b/types/go/services/management.mb.go index b899dad1..5e9b6eba 100644 --- a/types/go/services/management.mb.go +++ b/types/go/services/management.mb.go @@ -162,13 +162,15 @@ func (x *GetSubscriptionStatusInput) StringReference() (res string) { type GetSubscriptionStatusOutput struct { SubscriptionStatusIsActive bool + SubscriptionMaxKeys primitives.StorageKeys + SubscriptionMaxSize primitives.StorageSizeMegabyte } func (x *GetSubscriptionStatusOutput) String() string { if x == nil { return "" } - return fmt.Sprintf("{SubscriptionStatusIsActive:%s,}", x.StringSubscriptionStatusIsActive()) + return fmt.Sprintf("{SubscriptionStatusIsActive:%s,SubscriptionMaxKeys:%s,SubscriptionMaxSize:%s,}", x.StringSubscriptionStatusIsActive(), x.StringSubscriptionMaxKeys(), x.StringSubscriptionMaxSize()) } func (x *GetSubscriptionStatusOutput) StringSubscriptionStatusIsActive() (res string) { @@ -176,6 +178,16 @@ func (x *GetSubscriptionStatusOutput) StringSubscriptionStatusIsActive() (res st return } +func (x *GetSubscriptionStatusOutput) StringSubscriptionMaxKeys() (res string) { + res = fmt.Sprintf("%s", x.SubscriptionMaxKeys) + return +} + +func (x *GetSubscriptionStatusOutput) StringSubscriptionMaxSize() (res string) { + res = fmt.Sprintf("%s", x.SubscriptionMaxSize) + return +} + ///////////////////////////////////////////////////////////////////////////// // message GetCommitteeInput (non serializable) diff --git a/types/go/services/state_storage.mb.go b/types/go/services/state_storage.mb.go index a8c608b5..d5c62198 100644 --- a/types/go/services/state_storage.mb.go +++ b/types/go/services/state_storage.mb.go @@ -98,13 +98,15 @@ type GetLastCommittedBlockInfoOutput struct { BlockProposerAddress primitives.NodeAddress CurrentReferenceTime primitives.TimestampSeconds PrevReferenceTime primitives.TimestampSeconds + CurrentNumKeys primitives.StorageKeys + CurrentSize primitives.StorageSizeMegabyte } func (x *GetLastCommittedBlockInfoOutput) String() string { if x == nil { return "" } - return fmt.Sprintf("{BlockHeight:%s,BlockTimestamp:%s,BlockProposerAddress:%s,CurrentReferenceTime:%s,PrevReferenceTime:%s,}", x.StringBlockHeight(), x.StringBlockTimestamp(), x.StringBlockProposerAddress(), x.StringCurrentReferenceTime(), x.StringPrevReferenceTime()) + return fmt.Sprintf("{BlockHeight:%s,BlockTimestamp:%s,BlockProposerAddress:%s,CurrentReferenceTime:%s,PrevReferenceTime:%s,CurrentNumKeys:%s,CurrentSize:%s,}", x.StringBlockHeight(), x.StringBlockTimestamp(), x.StringBlockProposerAddress(), x.StringCurrentReferenceTime(), x.StringPrevReferenceTime(), x.StringCurrentNumKeys(), x.StringCurrentSize()) } func (x *GetLastCommittedBlockInfoOutput) StringBlockHeight() (res string) { @@ -132,6 +134,16 @@ func (x *GetLastCommittedBlockInfoOutput) StringPrevReferenceTime() (res string) return } +func (x *GetLastCommittedBlockInfoOutput) StringCurrentNumKeys() (res string) { + res = fmt.Sprintf("%s", x.CurrentNumKeys) + return +} + +func (x *GetLastCommittedBlockInfoOutput) StringCurrentSize() (res string) { + res = fmt.Sprintf("%s", x.CurrentSize) + return +} + ///////////////////////////////////////////////////////////////////////////// // message CommitStateDiffInput (non serializable)