store: Put call cache operations in a transaction
@@ -1180,7 +1180,7 @@ impl EthereumCallCache for Store {
let id = contract_call_id(contract_address, encoded_call, block);
let conn = &*self.get_conn()?;
-
+ conn.transaction(|| {
if let Some((return_value, update_accessed_at)) = eth_call_cache::table
.find(id.as_ref())
.inner_join(eth_call_meta::table)
@@ -1200,6 +1200,7 @@ impl EthereumCallCache for Store {
} else {
Ok(None)
}
+ })
}
fn set_call(
@@ -1214,7 +1215,7 @@ impl EthereumCallCache for Store {
let id = contract_call_id(contract_address, encoded_call, block);
let conn = &*self.get_conn()?;
-
+ conn.transaction(|| {
insert_into(eth_call_cache::table)
.values((
eth_call_cache::id.eq(id.as_ref()),
@@ -1237,6 +1238,7 @@ impl EthereumCallCache for Store {
.execute(conn)
.map(|_| ())
.map_err(Error::from)
+ })
}
}
