Skip to content

chore: remove unused code #10718

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 0 additions & 44 deletions crates/anvil/src/eth/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ pub struct EthApi {
/// Holds all blockchain related data
/// In-Memory only for now
pub backend: Arc<backend::mem::Backend>,
/// Whether this node is mining
is_mining: bool,
/// available signers
signers: Arc<Vec<Box<dyn Signer>>>,
/// data required for `eth_feeHistory`
Expand Down Expand Up @@ -155,7 +153,6 @@ impl EthApi {
Self {
pool,
backend,
is_mining: true,
signers,
fee_history_cache,
fee_history_limit,
Expand Down Expand Up @@ -567,38 +564,6 @@ impl EthApi {
Ok(alloy_primitives::hex::encode_prefixed(&hash[..]))
}

/// Returns protocol version encoded as a string (quotes are necessary).
///
/// Handler for ETH RPC call: `eth_protocolVersion`
pub fn protocol_version(&self) -> Result<u64> {
node_info!("eth_protocolVersion");
Ok(1)
}

/// Returns the number of hashes per second that the node is mining with.
///
/// Handler for ETH RPC call: `eth_hashrate`
pub fn hashrate(&self) -> Result<U256> {
node_info!("eth_hashrate");
Ok(U256::ZERO)
}

/// Returns the client coinbase address.
///
/// Handler for ETH RPC call: `eth_coinbase`
pub fn author(&self) -> Result<Address> {
node_info!("eth_coinbase");
Ok(self.backend.coinbase())
}

/// Returns true if client is actively mining new blocks.
///
/// Handler for ETH RPC call: `eth_mining`
pub fn is_mining(&self) -> Result<bool> {
node_info!("eth_mining");
Ok(self.is_mining)
}
Comment on lines -570 to -600
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should likely be implemented, they are currently not


/// Returns the chain ID used for transaction signing at the
/// current best block. None is returned if not
/// available.
Expand Down Expand Up @@ -2419,15 +2384,6 @@ impl EthApi {
Ok(blocks)
}

/// Sets the reported block number
///
/// Handler for ETH RPC call: `anvil_setBlock`
pub fn anvil_set_block(&self, block_number: u64) -> Result<()> {
node_info!("anvil_setBlock");
self.backend.set_block_number(block_number);
Ok(())
}
Comment on lines -2422 to -2429
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be implemented instead of removed


/// Sets the backend rpc url
///
/// Handler for ETH RPC call: `anvil_setRpcUrl`
Expand Down
7 changes: 0 additions & 7 deletions crates/anvil/src/eth/backend/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,6 @@ pub trait Db:
fn current_state(&self) -> StateDb;
}

impl dyn Db {
// TODO: Required until trait upcasting is stabilized: <https://github.com/rust-lang/rust/issues/65991>
pub fn as_dbref(&self) -> &dyn DatabaseRef<Error = DatabaseError> {
self.as_dyn()
}
}

/// Convenience impl only used to use any `Db` on the fly as the db layer for revm's CacheDB
/// This is useful to create blocks without actually writing to the `Db`, but rather in the cache of
/// the `CacheDB` see also
Expand Down
10 changes: 0 additions & 10 deletions crates/anvil/src/eth/backend/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,6 @@ impl StorageInfo {
Self { backend }
}

/// Returns the receipts of the current block
pub fn current_receipts(&self) -> Option<Vec<TypedReceipt>> {
self.backend.mined_receipts(self.backend.best_hash())
}

/// Returns the current block
pub fn current_block(&self) -> Option<Block> {
self.backend.get_block(self.backend.best_number())
}

/// Returns the receipts of the block with the given hash
pub fn receipts(&self, hash: B256) -> Option<Vec<TypedReceipt>> {
self.backend.mined_receipts(hash)
Expand Down
5 changes: 0 additions & 5 deletions crates/anvil/src/eth/backend/mem/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,11 +486,6 @@ impl Blockchain {
pub fn get_transaction_by_hash(&self, hash: &B256) -> Option<MinedTransaction> {
self.storage.read().transactions.get(hash).cloned()
}

/// Returns the total number of blocks
pub fn blocks_count(&self) -> usize {
self.storage.read().blocks.len()
}
}

/// Represents the outcome of mining a new block
Expand Down
Loading
Loading