mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 11:31:08 +03:00
Http adapter Fix (#2295)
* only send http and keybase adapter slates sync * rustfmt
This commit is contained in:
parent
16878dc6a2
commit
dca9462669
1 changed files with 22 additions and 11 deletions
|
@ -343,18 +343,20 @@ where
|
||||||
return Err(e);
|
return Err(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let adapter = match args.method.as_ref() {
|
match args.method.as_ref() {
|
||||||
"http" => HTTPWalletCommAdapter::new(),
|
"http" => slate = HTTPWalletCommAdapter::new().send_tx_sync(&args.dest, &slate)?,
|
||||||
"file" => FileWalletCommAdapter::new(),
|
"file" => {
|
||||||
"keybase" => KeybaseWalletCommAdapter::new(),
|
FileWalletCommAdapter::new().send_tx_async(&args.dest, &slate)?;
|
||||||
|
}
|
||||||
|
"keybase" => {
|
||||||
|
//TODO: in case of keybase, the response might take 60s and leave the service hanging
|
||||||
|
slate = KeybaseWalletCommAdapter::new().send_tx_sync(&args.dest, &slate)?;
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
error!("unsupported payment method: {}", args.method);
|
error!("unsupported payment method: {}", args.method);
|
||||||
return Err(ErrorKind::ClientCallback("unsupported payment method"))?;
|
return Err(ErrorKind::ClientCallback("unsupported payment method"))?;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
// TODO: improve it:
|
|
||||||
// in case of keybase, the response might take 60s and leave the service hanging
|
|
||||||
slate = adapter.send_tx_sync(&args.dest, &slate)?;
|
|
||||||
api.tx_lock_outputs(&slate, lock_fn)?;
|
api.tx_lock_outputs(&slate, lock_fn)?;
|
||||||
if args.method != "file" {
|
if args.method != "file" {
|
||||||
api.finalize_tx(&mut slate)?;
|
api.finalize_tx(&mut slate)?;
|
||||||
|
@ -643,7 +645,10 @@ fn create_error_response(e: Error) -> Response<Body> {
|
||||||
Response::builder()
|
Response::builder()
|
||||||
.status(StatusCode::INTERNAL_SERVER_ERROR)
|
.status(StatusCode::INTERNAL_SERVER_ERROR)
|
||||||
.header("access-control-allow-origin", "*")
|
.header("access-control-allow-origin", "*")
|
||||||
.header("access-control-allow-headers", "Content-Type, Authorization")
|
.header(
|
||||||
|
"access-control-allow-headers",
|
||||||
|
"Content-Type, Authorization",
|
||||||
|
)
|
||||||
.body(format!("{}", e).into())
|
.body(format!("{}", e).into())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
@ -652,7 +657,10 @@ fn create_ok_response(json: &str) -> Response<Body> {
|
||||||
Response::builder()
|
Response::builder()
|
||||||
.status(StatusCode::OK)
|
.status(StatusCode::OK)
|
||||||
.header("access-control-allow-origin", "*")
|
.header("access-control-allow-origin", "*")
|
||||||
.header("access-control-allow-headers", "Content-Type, Authorization")
|
.header(
|
||||||
|
"access-control-allow-headers",
|
||||||
|
"Content-Type, Authorization",
|
||||||
|
)
|
||||||
.body(json.to_string().into())
|
.body(json.to_string().into())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
@ -661,7 +669,10 @@ fn response<T: Into<Body>>(status: StatusCode, text: T) -> Response<Body> {
|
||||||
Response::builder()
|
Response::builder()
|
||||||
.status(status)
|
.status(status)
|
||||||
.header("access-control-allow-origin", "*")
|
.header("access-control-allow-origin", "*")
|
||||||
.header("access-control-allow-headers", "Content-Type, Authorization")
|
.header(
|
||||||
|
"access-control-allow-headers",
|
||||||
|
"Content-Type, Authorization",
|
||||||
|
)
|
||||||
.body(text.into())
|
.body(text.into())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue