Skip to content

Commit

Permalink
grpc: Add datastoreusage command
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Neuroth <[email protected]>
  • Loading branch information
nepet committed Oct 24, 2023
1 parent a8118f0 commit 9101ad9
Show file tree
Hide file tree
Showing 6 changed files with 450 additions and 319 deletions.
13 changes: 13 additions & 0 deletions cln-grpc/proto/node.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions cln-grpc/src/convert.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions cln-grpc/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,38 @@ async fn datastore(

}

async fn datastore_usage(
&self,
request: tonic::Request<pb::DatastoreusageRequest>,
) -> Result<tonic::Response<pb::DatastoreusageResponse>, tonic::Status> {
let req = request.into_inner();
let req: requests::DatastoreusageRequest = req.into();
debug!("Client asked for datastore_usage");
trace!("datastore_usage request: {:?}", req);
let mut rpc = ClnRpc::new(&self.rpc_path)
.await
.map_err(|e| Status::new(Code::Internal, e.to_string()))?;
let result = rpc.call(Request::DatastoreUsage(req))
.await
.map_err(|e| Status::new(
Code::Unknown,
format!("Error calling method DatastoreUsage: {:?}", e)))?;
match result {
Response::DatastoreUsage(r) => {
trace!("datastore_usage response: {:?}", r);
Ok(tonic::Response::new(r.into()))
},
r => Err(Status::new(
Code::Internal,
format!(
"Unexpected result {:?} to method call DatastoreUsage",
r
)
)),
}

}

async fn create_onion(
&self,
request: tonic::Request<pb::CreateonionRequest>,
Expand Down
644 changes: 325 additions & 319 deletions contrib/pyln-grpc-proto/pyln/grpc/node_pb2.py

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions contrib/pyln-grpc-proto/pyln/grpc/node_pb2_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ def __init__(self, channel):
request_serializer=node__pb2.DatastoreRequest.SerializeToString,
response_deserializer=node__pb2.DatastoreResponse.FromString,
)
self.DatastoreUsage = channel.unary_unary(
'/cln.Node/DatastoreUsage',
request_serializer=node__pb2.DatastoreusageRequest.SerializeToString,
response_deserializer=node__pb2.DatastoreusageResponse.FromString,
)
self.CreateOnion = channel.unary_unary(
'/cln.Node/CreateOnion',
request_serializer=node__pb2.CreateonionRequest.SerializeToString,
Expand Down Expand Up @@ -381,6 +386,12 @@ def Datastore(self, request, context):
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def DatastoreUsage(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def CreateOnion(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
Expand Down Expand Up @@ -720,6 +731,11 @@ def add_NodeServicer_to_server(servicer, server):
request_deserializer=node__pb2.DatastoreRequest.FromString,
response_serializer=node__pb2.DatastoreResponse.SerializeToString,
),
'DatastoreUsage': grpc.unary_unary_rpc_method_handler(
servicer.DatastoreUsage,
request_deserializer=node__pb2.DatastoreusageRequest.FromString,
response_serializer=node__pb2.DatastoreusageResponse.SerializeToString,
),
'CreateOnion': grpc.unary_unary_rpc_method_handler(
servicer.CreateOnion,
request_deserializer=node__pb2.CreateonionRequest.FromString,
Expand Down Expand Up @@ -1164,6 +1180,23 @@ def Datastore(request,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def DatastoreUsage(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/cln.Node/DatastoreUsage',
node__pb2.DatastoreusageRequest.SerializeToString,
node__pb2.DatastoreusageResponse.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def CreateOnion(request,
target,
Expand Down
12 changes: 12 additions & 0 deletions contrib/pyln-testing/pyln/testing/grpc2py.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,18 @@ def datastore2py(m):
})


def datastoreusage_datastoreusage2py(m):
return remove_default({
"key": m.key, # PrimitiveField in generate_composite
"total_bytes": m.total_bytes, # PrimitiveField in generate_composite
})


def datastoreusage2py(m):
return remove_default({
})


def createonion2py(m):
return remove_default({
"onion": hexlify(m.onion), # PrimitiveField in generate_composite
Expand Down

0 comments on commit 9101ad9

Please sign in to comment.