msggen: Do not override method names when loading Schema

We were overriding the name right when loading, which is bad since in
some languages we use the method name as tag in the requests, thus
renaming causes us to call something that isn't defined.

Changelog-Fixed: cln-rpc: Fixed a naming mismatch for `ConnectPeer` causing `connectpeer` to be called on the JSON-RPC
This commit is contained in:
Christian Decker
2022-06-30 10:38:32 +02:00
committed by Rusty Russell
parent 5979a7778f
commit 2d35c9a929
3 changed files with 7 additions and 13 deletions

View File

@@ -325,20 +325,20 @@ async fn connect_peer(
let mut rpc = ClnRpc::new(&self.rpc_path)
.await
.map_err(|e| Status::new(Code::Internal, e.to_string()))?;
let result = rpc.call(Request::ConnectPeer(req))
let result = rpc.call(Request::Connect(req))
.await
.map_err(|e| Status::new(
Code::Unknown,
format!("Error calling method ConnectPeer: {:?}", e)))?;
format!("Error calling method Connect: {:?}", e)))?;
match result {
Response::ConnectPeer(r) => {
Response::Connect(r) => {
trace!("connect_peer response: {:?}", r);
Ok(tonic::Response::new((&r).into()))
},
r => Err(Status::new(
Code::Internal,
format!(
"Unexpected result {:?} to method call ConnectPeer",
"Unexpected result {:?} to method call Connect",
r
)
)),

View File

@@ -25,7 +25,7 @@ pub enum Request {
AutoCleanInvoice(requests::AutocleaninvoiceRequest),
CheckMessage(requests::CheckmessageRequest),
Close(requests::CloseRequest),
ConnectPeer(requests::ConnectRequest),
Connect(requests::ConnectRequest),
CreateInvoice(requests::CreateinvoiceRequest),
Datastore(requests::DatastoreRequest),
CreateOnion(requests::CreateonionRequest),
@@ -75,7 +75,7 @@ pub enum Response {
AutoCleanInvoice(responses::AutocleaninvoiceResponse),
CheckMessage(responses::CheckmessageResponse),
Close(responses::CloseResponse),
ConnectPeer(responses::ConnectResponse),
Connect(responses::ConnectResponse),
CreateInvoice(responses::CreateinvoiceResponse),
Datastore(responses::DatastoreResponse),
CreateOnion(responses::CreateonionResponse),

View File

@@ -4,12 +4,6 @@ from pathlib import Path
from msggen.model import Method, CompositeField, Service
# Sometimes we want to rename a method, due to a name clash
# FIXME: need to be generalized?
method_name_override = {
"Connect": "ConnectPeer",
}
def repo_root():
path = subprocess.check_output(["git", "rev-parse", "--show-toplevel"])
@@ -34,7 +28,7 @@ def load_jsonrpc_method(name, schema_dir: str = None):
response.typename += "Response"
return Method(
name=method_name_override.get(name, name),
name,
request=request,
response=response,
)