-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
23b6c5b
commit d4d84f2
Showing
8 changed files
with
73 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
bot/crates/artemis-core/src/collectors/mevshare_collector.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use crate::types::{Collector, CollectorStream}; | ||
use anyhow::Result; | ||
use async_trait::async_trait; | ||
pub use mev_share_sse::Event; | ||
use mev_share_sse::EventClient; | ||
use tokio_stream::StreamExt; | ||
|
||
/// A collector that streams from MEV-Share SSE endpoint | ||
/// and generates [events](Event), which return tx hash, logs, and bundled txs. | ||
#[derive(Debug, Clone)] | ||
pub struct MevShareCollector { | ||
mevshare_sse_url: String, | ||
} | ||
|
||
impl MevShareCollector { | ||
pub fn new(mevshare_sse_url: String) -> Self { | ||
Self { mevshare_sse_url } | ||
} | ||
} | ||
|
||
/// Implementation of the [Collector](Collector) trait for the | ||
/// [MevShareCollector](MevShareCollector). | ||
#[async_trait] | ||
impl Collector<Event> for MevShareCollector { | ||
async fn get_event_stream(&self) -> Result<CollectorStream<'_, Event>> { | ||
let client = EventClient::default(); | ||
let stream = client.events(&self.mevshare_sse_url).await.unwrap(); | ||
let stream = stream.filter_map(|event| match event { | ||
Ok(evt) => Some(evt), | ||
Err(_) => None, | ||
}); | ||
Ok(Box::pin(stream)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters