Skip to content

Commit

Permalink
Remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
Lohann committed Sep 2, 2024
1 parent b68dbc2 commit 8c90987
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 221 deletions.
83 changes: 0 additions & 83 deletions chains/ethereum/server/src/block_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,86 +366,3 @@ where
Ok(guard.0.clone())
}
}

// /// A block stream that fetches blocks in order
// pub struct OrderedBlockStream<P> {
// provider: P,
// /// Maximum number of blocks to fetch concurrently
// capacity: usize,
// /// requests which have been queued for later processing
// pending: BTreeSet<BlockRef>,
// /// requests which are currently underway
// fut: FuturesUnordered<BlockFuture<BoxFuture<'static, Option<SealedBlock<H256>>>>>,
// }

// impl<P: BlockProvider> OrderedBlockStream<P> {
// pub fn new(provider: P, capacity: usize) -> Self {
// Self { provider, capacity, pending: BTreeSet::new(), fut: FuturesUnordered::new() }
// }

// pub fn fetch(&mut self, block_ref: BlockRef) -> Option<bool> {
// if self.pending.contains(&block_ref) {
// Some(false)
// } else if self.fut.len() < self.capacity {
// self.pending.insert(block_ref);
// self.fut
// .push(BlockFuture { block_ref, future: self.callback.get_block(block_ref) });
// Ok(())
// } else {
// Err(())
// }
// }

// pub fn len(&self) -> usize {
// self.fut.len()
// }

// pub fn is_empty(&self) -> bool {
// self.fut.is_empty()
// }
// }

// impl<P: BlockProvider> Stream for OrderedBlockStream<P> {
// type Item = Result<SealedBlock<H256>, F::Error>;

// fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
// if self.fut.is_empty() {
// return Poll::Ready(None);
// }
// let future = unsafe { Pin::new_unchecked(&mut self.fut) };
// match future.poll_next(cx) {
// Poll::Ready(Some((block_ref, result))) => {
// self.pending.remove(&block_ref);
// Poll::Ready(Some(result))
// },
// Poll::Ready(None) => Poll::Ready(None),
// Poll::Pending => Poll::Pending,
// }
// }

// fn size_hint(&self) -> (usize, Option<usize>) {
// (self.fut.len(), None)
// }
// }

// struct BlockFuture<Fut> {
// block_ref: BlockRef,
// future: Fut,
// }

// impl<Fut> Unpin for BlockFuture<Fut> where Fut: Unpin {}
// impl<Fut> Future for BlockFuture<Fut>
// where
// Fut: Future,
// {
// type Output = (BlockRef, Fut::Output);

// fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
// let this = unsafe { self.get_unchecked_mut() };
// let pinned = unsafe { Pin::new_unchecked(&mut this.future) };
// match pinned.poll(cx) {
// Poll::Ready(output) => Poll::Ready((this.block_ref, output)),
// Poll::Pending => Poll::Pending,
// }
// }
// }
2 changes: 0 additions & 2 deletions chains/ethereum/server/src/block_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ use rosetta_ethereum_backend::{
EthereumPubSub,
};
use std::{
// collections::VecDeque,
pin::Pin,
task::{Context, Poll},
};
// use tinyvec::TinyVec;

pub struct BlockStream<P, RPC>
where
Expand Down
93 changes: 0 additions & 93 deletions chains/ethereum/server/src/chain_sync.rs

This file was deleted.

3 changes: 0 additions & 3 deletions chains/ethereum/server/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,6 @@ where

impl<P> EthereumClient<P>
where
// P: BlockProvider + Unpin + Send + Sync + 'static,
// P::FinalizedFut: Unpin + Send + Sync + 'static,
// P::Error: std::error::Error,
P: SubscriptionClientT + Unpin + Clone + Send + Sync + 'static,
{
#[allow(clippy::missing_errors_doc)]
Expand Down
1 change: 0 additions & 1 deletion chains/ethereum/server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use url::Url;

mod block_provider;
mod block_stream;
// mod chain_sync;
mod client;
mod event_stream;
mod finalized_block_stream;
Expand Down
31 changes: 0 additions & 31 deletions chains/ethereum/server/src/log_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ impl LogFilter {
#[cfg(test)]
mod tests {
use super::*;
// use hex_literal::hex;
// use rosetta_config_ethereum::ext::types::Bloom;

#[test]
fn add_remove_works() {
Expand All @@ -71,33 +69,4 @@ mod tests {
assert!(filter.remove(&address).is_none());
assert!(filter.is_empty());
}

// #[test]
// fn filter_topics_works() {
// let mut filter = LogFilter::new();
// let logs_bloom =
// Bloom::from(hex!("
// 00000000000000000000000000000000000000000000020200040000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000002000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000200000000000000000"
// ));

// // Empty filter
// let mut logs = filter.topics_from_bloom(logs_bloom);
// assert!(logs.next().is_none());
// drop(logs);

// let expect_address = Address::from(hex!("97be939b2eb5a462c634414c8134b09ebad04d83"));
// let expect_topics = [
// H256(hex!("b7dbf4f78c37528484cb9761beaca968c613f3c6c534b25b1988b912413c68bc")),
// H256(hex!("fca76ae197bb7f913a92bd1f31cb362d0fdbf27b2cc56d8b9bc22d0d76c58dc8")),
// ];
// filter.add(expect_address, expect_topics.into_iter());

// let mut logs = filter.topics_from_bloom(logs_bloom);
// let (address, mut topics) = logs.next().unwrap();
// assert_eq!(address, expect_address);
// assert_eq!(topics.next().unwrap(), expect_topics[0]);
// assert_eq!(topics.next().unwrap(), expect_topics[1]);
// assert!(logs.next().is_none());
// assert!(topics.next().is_none());
// }
}
9 changes: 1 addition & 8 deletions chains/ethereum/server/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ impl StateInner {
self.finalized_blocks.push_back(finalized_block_ref);

// Remove retracted blocks
let head_block_number = finalized_block_ref.number + 1;
let finalized_blocks = &self.finalized_blocks;
let mut removed = self
.blocks
Expand All @@ -277,13 +276,7 @@ impl StateInner {
return false;
}
// Check if the block exists in the fork tree
let exists =
self.fork_tree.iter().any(|(block_ref, _, _)| block_ref.hash == block.hash());
if exists {
return false;
}
// Check if the block is descendent of the finalized block
block.number() < head_block_number
!self.fork_tree.iter().any(|(block_ref, _, _)| block_ref.hash == block.hash())
})
.map(|(_, block)| block)
.collect::<Vec<_>>();
Expand Down

0 comments on commit 8c90987

Please sign in to comment.