From c32760b19c41fc08def2728b956a23274b6941f7 Mon Sep 17 00:00:00 2001 From: warittornc <69615455+warittornc@users.noreply.github.com> Date: Fri, 1 Nov 2024 15:47:43 +0700 Subject: [PATCH] [feat] Add More Details to GetInfo (#94) * add active sources and monitoring enabled to get info * fixed typo --- .../go-client/proto/bothan/v1/bothan.pb.go | 158 ++++++++++-------- bothan-api/server/src/api/server.rs | 2 + bothan-api/server/src/proto/bothan.v1.rs | 8 +- .../src/manager/crypto_asset_info/manager.rs | 16 +- .../src/manager/crypto_asset_info/types.rs | 6 + bothan-core/src/monitoring/client.rs | 4 +- bothan-core/src/monitoring/types.rs | 12 +- proto/bothan/v1/bothan.proto | 6 +- 8 files changed, 122 insertions(+), 90 deletions(-) diff --git a/bothan-api/client/go-client/proto/bothan/v1/bothan.pb.go b/bothan-api/client/go-client/proto/bothan/v1/bothan.pb.go index a53d2ba6..3799e68e 100644 --- a/bothan-api/client/go-client/proto/bothan/v1/bothan.pb.go +++ b/bothan-api/client/go-client/proto/bothan/v1/bothan.pb.go @@ -123,12 +123,16 @@ type GetInfoResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // The bothan version + // The Bothan version BothanVersion string `protobuf:"bytes,1,opt,name=bothan_version,json=bothanVersion,proto3" json:"bothan_version,omitempty"` // The IPFS hash pointing to the registry data. RegistryIpfsHash string `protobuf:"bytes,2,opt,name=registry_ipfs_hash,json=registryIpfsHash,proto3" json:"registry_ipfs_hash,omitempty"` // The version requirements for the registry. RegistryVersionRequirement string `protobuf:"bytes,3,opt,name=registry_version_requirement,json=registryVersionRequirement,proto3" json:"registry_version_requirement,omitempty"` + // The active sources the Bothan instance is using + ActiveSources []string `protobuf:"bytes,4,rep,name=active_sources,json=activeSources,proto3" json:"active_sources,omitempty"` + // Whether or not the Bothan instance has monitoring enabled + MonitoringEnabled bool `protobuf:"varint,5,opt,name=monitoring_enabled,json=monitoringEnabled,proto3" json:"monitoring_enabled,omitempty"` } func (x *GetInfoResponse) Reset() { @@ -184,6 +188,20 @@ func (x *GetInfoResponse) GetRegistryVersionRequirement() string { return "" } +func (x *GetInfoResponse) GetActiveSources() []string { + if x != nil { + return x.ActiveSources + } + return nil +} + +func (x *GetInfoResponse) GetMonitoringEnabled() bool { + if x != nil { + return x.MonitoringEnabled + } + return false +} + // UpdateRegistryRequest defines the request message for the UpdateRegistry RPC method. type UpdateRegistryRequest struct { state protoimpl.MessageState @@ -560,7 +578,7 @@ var file_bothan_v1_bothan_proto_rawDesc = []byte{ 0x2e, 0x76, 0x31, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x10, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x22, 0xa8, 0x01, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, + 0x65, 0x73, 0x74, 0x22, 0xfe, 0x01, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x62, 0x6f, 0x74, 0x68, 0x61, 0x6e, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x62, 0x6f, 0x74, 0x68, 0x61, 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2c, @@ -570,73 +588,79 @@ var file_bothan_v1_bothan_proto_rawDesc = []byte{ 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x1a, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x56, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x4e, - 0x0a, 0x15, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x69, 0x70, 0x66, 0x73, 0x5f, - 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x69, 0x70, 0x66, 0x73, - 0x48, 0x61, 0x73, 0x68, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x18, - 0x0a, 0x16, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x4b, 0x0a, 0x1c, 0x50, 0x75, 0x73, 0x68, - 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x17, 0x0a, 0x07, - 0x74, 0x78, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, - 0x78, 0x48, 0x61, 0x73, 0x68, 0x22, 0x1f, 0x0a, 0x1d, 0x50, 0x75, 0x73, 0x68, 0x4d, 0x6f, 0x6e, - 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x31, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x50, 0x72, 0x69, - 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x69, - 0x67, 0x6e, 0x61, 0x6c, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, - 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x49, 0x64, 0x73, 0x22, 0x51, 0x0a, 0x11, 0x47, 0x65, 0x74, - 0x50, 0x72, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, + 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x25, + 0x0a, 0x0e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, + 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0d, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x53, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x12, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, + 0x69, 0x6e, 0x67, 0x5f, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x11, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x45, 0x6e, 0x61, + 0x62, 0x6c, 0x65, 0x64, 0x22, 0x4e, 0x0a, 0x15, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, + 0x09, 0x69, 0x70, 0x66, 0x73, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x69, 0x70, 0x66, 0x73, 0x48, 0x61, 0x73, 0x68, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x18, 0x0a, 0x16, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x4b, + 0x0a, 0x1c, 0x50, 0x75, 0x73, 0x68, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, + 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, - 0x69, 0x64, 0x12, 0x28, 0x0a, 0x06, 0x70, 0x72, 0x69, 0x63, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x62, 0x6f, 0x74, 0x68, 0x61, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x50, - 0x72, 0x69, 0x63, 0x65, 0x52, 0x06, 0x70, 0x72, 0x69, 0x63, 0x65, 0x73, 0x22, 0x65, 0x0a, 0x05, - 0x50, 0x72, 0x69, 0x63, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x5f, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, - 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x04, 0x52, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x12, 0x29, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x11, 0x2e, 0x62, 0x6f, 0x74, 0x68, 0x61, - 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x2a, 0x66, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, - 0x12, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, - 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, - 0x55, 0x4e, 0x53, 0x55, 0x50, 0x50, 0x4f, 0x52, 0x54, 0x45, 0x44, 0x10, 0x01, 0x12, 0x16, 0x0a, - 0x12, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x41, 0x56, 0x41, 0x49, 0x4c, 0x41, - 0x42, 0x4c, 0x45, 0x10, 0x02, 0x12, 0x14, 0x0a, 0x10, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, - 0x41, 0x56, 0x41, 0x49, 0x4c, 0x41, 0x42, 0x4c, 0x45, 0x10, 0x03, 0x32, 0xba, 0x03, 0x0a, 0x0d, - 0x42, 0x6f, 0x74, 0x68, 0x61, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x4f, 0x0a, - 0x07, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x19, 0x2e, 0x62, 0x6f, 0x74, 0x68, 0x61, - 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x62, 0x6f, 0x74, 0x68, 0x61, 0x6e, 0x2e, 0x76, 0x31, 0x2e, - 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x0d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x07, 0x12, 0x05, 0x2f, 0x69, 0x6e, 0x66, 0x6f, 0x12, 0x68, - 0x0a, 0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x12, 0x20, 0x2e, 0x62, 0x6f, 0x74, 0x68, 0x61, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x62, 0x6f, 0x74, 0x68, 0x61, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x22, 0x09, 0x2f, - 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x12, 0x87, 0x01, 0x0a, 0x15, 0x50, 0x75, 0x73, - 0x68, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x63, 0x6f, 0x72, - 0x64, 0x73, 0x12, 0x27, 0x2e, 0x62, 0x6f, 0x74, 0x68, 0x61, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x50, + 0x69, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x74, 0x78, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, 0x78, 0x48, 0x61, 0x73, 0x68, 0x22, 0x1f, 0x0a, 0x1d, 0x50, 0x75, 0x73, 0x68, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x63, - 0x6f, 0x72, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x62, 0x6f, - 0x74, 0x68, 0x61, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x4d, 0x6f, 0x6e, 0x69, - 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x15, 0x22, 0x13, 0x2f, - 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x72, 0x65, 0x63, 0x6f, 0x72, - 0x64, 0x73, 0x12, 0x64, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x50, 0x72, 0x69, 0x63, 0x65, 0x73, 0x12, - 0x1b, 0x2e, 0x62, 0x6f, 0x74, 0x68, 0x61, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, - 0x72, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x62, - 0x6f, 0x74, 0x68, 0x61, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x69, 0x63, - 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1c, 0x82, 0xd3, 0xe4, 0x93, - 0x02, 0x16, 0x12, 0x14, 0x2f, 0x70, 0x72, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x7b, 0x73, 0x69, 0x67, - 0x6e, 0x61, 0x6c, 0x5f, 0x69, 0x64, 0x73, 0x7d, 0x42, 0x2b, 0x5a, 0x29, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x6f, 0x74, 0x68, 0x61, 0x6e, 0x2f, 0x62, 0x6f, - 0x74, 0x68, 0x61, 0x6e, 0x2d, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x72, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x31, 0x0a, 0x10, + 0x47, 0x65, 0x74, 0x50, 0x72, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x49, 0x64, 0x73, 0x22, + 0x51, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x50, 0x72, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x28, 0x0a, 0x06, 0x70, 0x72, 0x69, 0x63, + 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x62, 0x6f, 0x74, 0x68, 0x61, + 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x69, 0x63, 0x65, 0x52, 0x06, 0x70, 0x72, 0x69, 0x63, + 0x65, 0x73, 0x22, 0x65, 0x0a, 0x05, 0x50, 0x72, 0x69, 0x63, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x73, + 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, + 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x69, 0x63, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x12, 0x29, + 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x11, + 0x2e, 0x62, 0x6f, 0x74, 0x68, 0x61, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2a, 0x66, 0x0a, 0x06, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, + 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x16, 0x0a, 0x12, 0x53, + 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x55, 0x50, 0x50, 0x4f, 0x52, 0x54, 0x45, + 0x44, 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, + 0x41, 0x56, 0x41, 0x49, 0x4c, 0x41, 0x42, 0x4c, 0x45, 0x10, 0x02, 0x12, 0x14, 0x0a, 0x10, 0x53, + 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x41, 0x56, 0x41, 0x49, 0x4c, 0x41, 0x42, 0x4c, 0x45, 0x10, + 0x03, 0x32, 0xba, 0x03, 0x0a, 0x0d, 0x42, 0x6f, 0x74, 0x68, 0x61, 0x6e, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x12, 0x4f, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x19, + 0x2e, 0x62, 0x6f, 0x74, 0x68, 0x61, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, + 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x62, 0x6f, 0x74, 0x68, + 0x61, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x0d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x07, 0x12, 0x05, 0x2f, + 0x69, 0x6e, 0x66, 0x6f, 0x12, 0x68, 0x0a, 0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x12, 0x20, 0x2e, 0x62, 0x6f, 0x74, 0x68, 0x61, 0x6e, 0x2e, + 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, + 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x62, 0x6f, 0x74, 0x68, 0x61, + 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x11, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x0b, 0x22, 0x09, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x12, 0x87, + 0x01, 0x0a, 0x15, 0x50, 0x75, 0x73, 0x68, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, + 0x67, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x12, 0x27, 0x2e, 0x62, 0x6f, 0x74, 0x68, 0x61, + 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, + 0x69, 0x6e, 0x67, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x28, 0x2e, 0x62, 0x6f, 0x74, 0x68, 0x61, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x75, + 0x73, 0x68, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x63, 0x6f, + 0x72, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1b, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x15, 0x22, 0x13, 0x2f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, + 0x5f, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x12, 0x64, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x50, + 0x72, 0x69, 0x63, 0x65, 0x73, 0x12, 0x1b, 0x2e, 0x62, 0x6f, 0x74, 0x68, 0x61, 0x6e, 0x2e, 0x76, + 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x62, 0x6f, 0x74, 0x68, 0x61, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x47, + 0x65, 0x74, 0x50, 0x72, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x1c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x16, 0x12, 0x14, 0x2f, 0x70, 0x72, 0x69, 0x63, 0x65, + 0x73, 0x2f, 0x7b, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x5f, 0x69, 0x64, 0x73, 0x7d, 0x42, 0x2b, + 0x5a, 0x29, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x6f, 0x74, + 0x68, 0x61, 0x6e, 0x2f, 0x62, 0x6f, 0x74, 0x68, 0x61, 0x6e, 0x2d, 0x61, 0x70, 0x69, 0x2f, 0x63, + 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( diff --git a/bothan-api/server/src/api/server.rs b/bothan-api/server/src/api/server.rs index 76319751..d2c29839 100644 --- a/bothan-api/server/src/api/server.rs +++ b/bothan-api/server/src/api/server.rs @@ -44,6 +44,8 @@ impl BothanService for BothanServer { bothan_version: info.bothan_version, registry_ipfs_hash: info.registry_hash, registry_version_requirement: info.registry_version_requirement, + active_sources: info.active_sources, + monitoring_enabled: info.monitoring_enabled, }); Ok(response) diff --git a/bothan-api/server/src/proto/bothan.v1.rs b/bothan-api/server/src/proto/bothan.v1.rs index 829d0b5b..ce0b6955 100644 --- a/bothan-api/server/src/proto/bothan.v1.rs +++ b/bothan-api/server/src/proto/bothan.v1.rs @@ -9,7 +9,7 @@ pub struct GetInfoRequest { #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetInfoResponse { - /// The bothan version + /// The Bothan version #[prost(string, tag="1")] pub bothan_version: ::prost::alloc::string::String, /// The IPFS hash pointing to the registry data. @@ -18,6 +18,12 @@ pub struct GetInfoResponse { /// The version requirements for the registry. #[prost(string, tag="3")] pub registry_version_requirement: ::prost::alloc::string::String, + /// The active sources the Bothan instance is using + #[prost(string, repeated, tag="4")] + pub active_sources: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + /// Whether or not the Bothan instance has monitoring enabled + #[prost(bool, tag="5")] + pub monitoring_enabled: bool, } /// UpdateRegistryRequest defines the request message for the UpdateRegistry RPC method. #[allow(clippy::derive_partial_eq_without_eq)] diff --git a/bothan-core/src/manager/crypto_asset_info/manager.rs b/bothan-core/src/manager/crypto_asset_info/manager.rs index 5a70de77..04fc0d26 100644 --- a/bothan-core/src/manager/crypto_asset_info/manager.rs +++ b/bothan-core/src/manager/crypto_asset_info/manager.rs @@ -66,11 +66,14 @@ impl<'a> CryptoAssetInfoManager<'a> { .await? .unwrap_or(String::new()); // If value doesn't exist, return an empty string let registry_version_requirement = self.registry_version_requirement.to_string(); + let active_sources = self.workers.keys().cloned().collect(); Ok(CryptoAssetManagerInfo::new( bothan_version, registry_hash, registry_version_requirement, + active_sources, + self.monitoring_client.is_some(), )) } @@ -82,7 +85,7 @@ impl<'a> CryptoAssetInfoManager<'a> { let uuid = create_uuid(); - let supported_sources = self.current_worker_set().await; + let active_sources = self.workers.keys().cloned().collect(); let bothan_version = self.bothan_version.clone(); let registry_hash = self .store @@ -92,22 +95,13 @@ impl<'a> CryptoAssetInfoManager<'a> { .unwrap_or_else(|| "".to_string()); client - .post_heartbeat( - uuid.clone(), - supported_sources, - bothan_version, - registry_hash, - ) + .post_heartbeat(uuid.clone(), active_sources, bothan_version, registry_hash) .await? .error_for_status()?; Ok(uuid) } - pub async fn current_worker_set(&self) -> Vec { - self.workers.keys().cloned().collect() - } - /// Gets the `Price` of the given signal ids. pub async fn get_prices( &self, diff --git a/bothan-core/src/manager/crypto_asset_info/types.rs b/bothan-core/src/manager/crypto_asset_info/types.rs index 1264d942..c1fbf3f2 100644 --- a/bothan-core/src/manager/crypto_asset_info/types.rs +++ b/bothan-core/src/manager/crypto_asset_info/types.rs @@ -25,6 +25,8 @@ pub struct CryptoAssetManagerInfo { pub bothan_version: String, pub registry_hash: String, pub registry_version_requirement: String, + pub active_sources: Vec, + pub monitoring_enabled: bool, } impl CryptoAssetManagerInfo { @@ -32,11 +34,15 @@ impl CryptoAssetManagerInfo { bothan_version: String, registry_hash: String, registry_version_requirement: String, + active_sources: Vec, + monitoring_enabled: bool, ) -> Self { CryptoAssetManagerInfo { bothan_version, registry_hash, registry_version_requirement, + active_sources, + monitoring_enabled, } } } diff --git a/bothan-core/src/monitoring/client.rs b/bothan-core/src/monitoring/client.rs index ca92089e..e14dd3e4 100644 --- a/bothan-core/src/monitoring/client.rs +++ b/bothan-core/src/monitoring/client.rs @@ -46,11 +46,11 @@ impl Client { pub async fn post_heartbeat( &self, uuid: String, - supported_sources: Vec, + active_sources: Vec, bothan_version: Version, registry_hash: String, ) -> Result { - let bothan_info = BothanInfo::new(supported_sources, bothan_version, registry_hash); + let bothan_info = BothanInfo::new(active_sources, bothan_version, registry_hash); self.post(uuid, Topic::Heartbeat, bothan_info).await } diff --git a/bothan-core/src/monitoring/types.rs b/bothan-core/src/monitoring/types.rs index 71c30208..68011899 100644 --- a/bothan-core/src/monitoring/types.rs +++ b/bothan-core/src/monitoring/types.rs @@ -13,19 +13,15 @@ pub enum Topic { } pub struct BothanInfo { - pub supported_sources: Vec, + pub active_sources: Vec, pub version: Version, pub registry_hash: String, } impl BothanInfo { - pub fn new( - supported_sources: Vec, - version: Version, - registry_hash: String, - ) -> BothanInfo { + pub fn new(active_sources: Vec, version: Version, registry_hash: String) -> BothanInfo { BothanInfo { - supported_sources, + active_sources, version, registry_hash, } @@ -38,7 +34,7 @@ impl Serialize for BothanInfo { S: serde::Serializer, { let mut state = serializer.serialize_struct("BothanInfo", 4)?; - state.serialize_field("supported_sources", &self.supported_sources)?; + state.serialize_field("active_sources", &self.active_sources)?; state.serialize_field("version", &self.version.to_string())?; state.serialize_field("registry_hash", &self.registry_hash)?; state.end() diff --git a/proto/bothan/v1/bothan.proto b/proto/bothan/v1/bothan.proto index 3dd99940..3a056503 100644 --- a/proto/bothan/v1/bothan.proto +++ b/proto/bothan/v1/bothan.proto @@ -35,12 +35,16 @@ message GetInfoRequest {} // GetInfoResponse defines the response message for the GetInfo RPC method. message GetInfoResponse { - // The bothan version + // The Bothan version string bothan_version = 1; // The IPFS hash pointing to the registry data. string registry_ipfs_hash = 2; // The version requirements for the registry. string registry_version_requirement = 3; + // The active sources the Bothan instance is using + repeated string active_sources = 4; + // Whether or not the Bothan instance has monitoring enabled + bool monitoring_enabled = 5; } // UpdateRegistryRequest defines the request message for the UpdateRegistry RPC method.