allow optional casting of engine client to full client

This commit is contained in:
Robert Habermeier
2017-09-05 17:24:35 +02:00
parent ad39446e87
commit 7d1c7a0474
9 changed files with 37 additions and 43 deletions

View File

@@ -58,7 +58,13 @@ impl ValidatorContract {
Box::new(move |a, d| client.as_ref()
.and_then(Weak::upgrade)
.ok_or("No client!".into())
.and_then(|c| c.transact_contract(a, d).map_err(|e| format!("Transaction import error: {}", e)))
.and_then(|c| {
match c.as_full_client() {
Some(c) => c.transact_contract(a, d)
.map_err(|e| format!("Transaction import error: {}", e)),
None => Err("No full client!".into()),
}
})
.map(|_| Default::default()))
}
}

View File

@@ -311,7 +311,12 @@ impl ValidatorSet for ValidatorSafeContract {
Box::new(move |addr, data| client.as_ref()
.and_then(Weak::upgrade)
.ok_or("No client!".into())
.and_then(|c| c.call_contract(id, addr, data))
.and_then(|c| {
match c.as_full_client() {
Some(c) => c.call_contract(id, addr, data),
None => Err("No full client!".into()),
}
})
.map(|out| (out, Vec::new()))) // generate no proofs in general
}