WIP async
This commit is contained in:
parent
5cea6489e1
commit
cdd11858f6
1 changed files with 15 additions and 14 deletions
|
@ -22,10 +22,10 @@ impl ToString for ExecMsg {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_tcbinfo(fmspc: Fmspc, update: Update) -> Value {
|
async fn get_tcbinfo(fmspc: Fmspc, update: Update) -> Value {
|
||||||
let url = format!("https://api.trustedservices.intel.com/sgx/certification/v4/tcb?fmspc={fmspc}&update={update}");
|
let url = format!("https://api.trustedservices.intel.com/sgx/certification/v4/tcb?fmspc={fmspc}&update={update}");
|
||||||
let body: String = reqwest::blocking::get(url)
|
let body: String = reqwest::get(url)
|
||||||
|
.await
|
||||||
.expect("url retrieval failed")
|
.expect("url retrieval failed")
|
||||||
.text()
|
.text()
|
||||||
.expect("could not read https response");
|
.expect("could not read https response");
|
||||||
|
@ -33,9 +33,9 @@ fn get_tcbinfo(fmspc: Fmspc, update: Update) -> Value {
|
||||||
tcbinfo
|
tcbinfo
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_fmspc_list() -> Vec<Fmspc> {
|
async fn get_fmspc_list() -> Vec<Fmspc> {
|
||||||
let body: String =
|
let body: String =
|
||||||
reqwest::blocking::get("https://api.trustedservices.intel.com/sgx/certification/v4/fmspcs")
|
reqwest::get("https://api.trustedservices.intel.com/sgx/certification/v4/fmspcs").await
|
||||||
.expect("url retrieval failed")
|
.expect("url retrieval failed")
|
||||||
.text()
|
.text()
|
||||||
.expect("could not read https response");
|
.expect("could not read https response");
|
||||||
|
@ -49,7 +49,8 @@ fn get_fmspc_list() -> Vec<Fmspc> {
|
||||||
fmspc_list
|
fmspc_list
|
||||||
}
|
}
|
||||||
|
|
||||||
fn upsert_tcbinfo() -> Result<(), &'static str> {
|
|
||||||
|
async fn upsert_tcbinfo() -> Result<(), &'static str> {
|
||||||
let data = fs::read_to_string("./standard").expect("Unable to read file");
|
let data = fs::read_to_string("./standard").expect("Unable to read file");
|
||||||
let mut store: HashMap<Fmspc, TcbInfo> = serde_json::from_str(&data).unwrap();
|
let mut store: HashMap<Fmspc, TcbInfo> = serde_json::from_str(&data).unwrap();
|
||||||
|
|
||||||
|
@ -71,11 +72,11 @@ fn upsert_tcbinfo() -> Result<(), &'static str> {
|
||||||
certificate: TCB_SIGNER.to_string(),
|
certificate: TCB_SIGNER.to_string(),
|
||||||
time: None,
|
time: None,
|
||||||
}};
|
}};
|
||||||
// if let Err(e) =
|
if let Err(e) =
|
||||||
let _ = client.tx_execute(&contract_address, &chain_id, 200000, &sender, execute_msg, "200000untrn");
|
client.tx_execute(&contract_address, &chain_id, 200000, &sender, execute_msg, "200000untrn").await
|
||||||
// {
|
{
|
||||||
// eprintln!("Error: {}", e);
|
eprintln!("Error: {}", e);
|
||||||
// }
|
}
|
||||||
println!("done");
|
println!("done");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -90,7 +91,7 @@ fn upsert_tcbinfo() -> Result<(), &'static str> {
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[tokio::main]
|
#[tokio::main]
|
||||||
pub fn main() {
|
pub async fn main() {
|
||||||
upsert_tcbinfo().expect("TCBInfo update failed");
|
upsert_tcbinfo().await.expect("TCBInfo update failed");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue