mirror of
https://github.com/status-im/evmc.git
synced 2025-02-23 16:38:06 +00:00
Merge pull request #444 from ethereum/rust-mutability
rust: remove unneeded mutability in ExecutionContext
This commit is contained in:
commit
ca74d1969f
@ -13,6 +13,11 @@ and this project adheres to [Semantic Versioning].
|
|||||||
which can be used to emulate Host behavior when testing VM implementations.
|
which can be used to emulate Host behavior when testing VM implementations.
|
||||||
[#456](https://github.com/ethereum/evmc/pull/456)
|
[#456](https://github.com/ethereum/evmc/pull/456)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- In the Rust bindings mark read-only functions in `ExecutionContext` as non-mutating.
|
||||||
|
[#444](https://github.com/ethereum/evmc/pull/444)
|
||||||
|
|
||||||
|
|
||||||
## [7.0.0] „Istanbul Ready” — 2019-11-11
|
## [7.0.0] „Istanbul Ready” — 2019-11-11
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ impl<'a> ExecutionContext<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Check if an account exists.
|
/// Check if an account exists.
|
||||||
pub fn account_exists(&mut self, address: &Address) -> bool {
|
pub fn account_exists(&self, address: &Address) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
assert!((*self.host).account_exists.is_some());
|
assert!((*self.host).account_exists.is_some());
|
||||||
(*self.host).account_exists.unwrap()(self.context, address as *const Address)
|
(*self.host).account_exists.unwrap()(self.context, address as *const Address)
|
||||||
@ -222,7 +222,7 @@ impl<'a> ExecutionContext<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Read from a storage key.
|
/// Read from a storage key.
|
||||||
pub fn get_storage(&mut self, address: &Address, key: &Bytes32) -> Bytes32 {
|
pub fn get_storage(&self, address: &Address, key: &Bytes32) -> Bytes32 {
|
||||||
unsafe {
|
unsafe {
|
||||||
assert!((*self.host).get_storage.is_some());
|
assert!((*self.host).get_storage.is_some());
|
||||||
(*self.host).get_storage.unwrap()(
|
(*self.host).get_storage.unwrap()(
|
||||||
@ -252,7 +252,7 @@ impl<'a> ExecutionContext<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get balance of an account.
|
/// Get balance of an account.
|
||||||
pub fn get_balance(&mut self, address: &Address) -> Uint256 {
|
pub fn get_balance(&self, address: &Address) -> Uint256 {
|
||||||
unsafe {
|
unsafe {
|
||||||
assert!((*self.host).get_balance.is_some());
|
assert!((*self.host).get_balance.is_some());
|
||||||
(*self.host).get_balance.unwrap()(self.context, address as *const Address)
|
(*self.host).get_balance.unwrap()(self.context, address as *const Address)
|
||||||
@ -260,7 +260,7 @@ impl<'a> ExecutionContext<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get code size of an account.
|
/// Get code size of an account.
|
||||||
pub fn get_code_size(&mut self, address: &Address) -> usize {
|
pub fn get_code_size(&self, address: &Address) -> usize {
|
||||||
unsafe {
|
unsafe {
|
||||||
assert!((*self.host).get_code_size.is_some());
|
assert!((*self.host).get_code_size.is_some());
|
||||||
(*self.host).get_code_size.unwrap()(self.context, address as *const Address)
|
(*self.host).get_code_size.unwrap()(self.context, address as *const Address)
|
||||||
@ -268,7 +268,7 @@ impl<'a> ExecutionContext<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get code hash of an account.
|
/// Get code hash of an account.
|
||||||
pub fn get_code_hash(&mut self, address: &Address) -> Bytes32 {
|
pub fn get_code_hash(&self, address: &Address) -> Bytes32 {
|
||||||
unsafe {
|
unsafe {
|
||||||
assert!((*self.host).get_code_size.is_some());
|
assert!((*self.host).get_code_size.is_some());
|
||||||
(*self.host).get_code_hash.unwrap()(self.context, address as *const Address)
|
(*self.host).get_code_hash.unwrap()(self.context, address as *const Address)
|
||||||
@ -276,7 +276,7 @@ impl<'a> ExecutionContext<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Copy code of an account.
|
/// Copy code of an account.
|
||||||
pub fn copy_code(&mut self, address: &Address, code_offset: usize, buffer: &mut [u8]) -> usize {
|
pub fn copy_code(&self, address: &Address, code_offset: usize, buffer: &mut [u8]) -> usize {
|
||||||
unsafe {
|
unsafe {
|
||||||
assert!((*self.host).copy_code.is_some());
|
assert!((*self.host).copy_code.is_some());
|
||||||
(*self.host).copy_code.unwrap()(
|
(*self.host).copy_code.unwrap()(
|
||||||
@ -338,7 +338,7 @@ impl<'a> ExecutionContext<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get block hash of an account.
|
/// Get block hash of an account.
|
||||||
pub fn get_block_hash(&mut self, num: i64) -> Bytes32 {
|
pub fn get_block_hash(&self, num: i64) -> Bytes32 {
|
||||||
unsafe {
|
unsafe {
|
||||||
assert!((*self.host).get_block_hash.is_some());
|
assert!((*self.host).get_block_hash.is_some());
|
||||||
(*self.host).get_block_hash.unwrap()(self.context, num)
|
(*self.host).get_block_hash.unwrap()(self.context, num)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user