mirror of
https://github.com/0xfnzero/solana-streamer.git
synced 2026-08-19 11:58:06 +00:00
update readme
This commit is contained in:
@@ -9,11 +9,9 @@ use std::sync::Arc;
|
||||
use tokio::sync::mpsc;
|
||||
use tokio::task::JoinHandle;
|
||||
use futures::StreamExt;
|
||||
use crate::instruction::{
|
||||
logs_events::DexEvent,
|
||||
logs_data::DexInstruction,
|
||||
logs_filters::LogFilter
|
||||
};
|
||||
use crate::{constants, instruction::{
|
||||
logs_data::DexInstruction, logs_events::DexEvent, logs_filters::LogFilter
|
||||
}};
|
||||
|
||||
/// Subscription handle containing task and unsubscribe logic
|
||||
pub struct SubscriptionHandle {
|
||||
@@ -35,14 +33,14 @@ pub async fn create_pubsub_client(ws_url: &str) -> PubsubClient {
|
||||
/// 启动订阅
|
||||
pub async fn tokens_subscription<F>(
|
||||
ws_url: &str,
|
||||
program_address: &str,
|
||||
commitment: CommitmentConfig,
|
||||
callback: F,
|
||||
) -> Result<SubscriptionHandle, Box<dyn std::error::Error>>
|
||||
where
|
||||
F: Fn(DexEvent) + Send + Sync + 'static,
|
||||
{
|
||||
let logs_filter = RpcTransactionLogsFilter::Mentions(vec![program_address.to_string()]);
|
||||
let program_address = constants::accounts::PUMPFUN.to_string();
|
||||
let logs_filter = RpcTransactionLogsFilter::Mentions(vec![program_address]);
|
||||
|
||||
let logs_config = RpcTransactionLogsConfig {
|
||||
commitment: Some(commitment),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use mai3_pumpfun_sdk::instruction::logs_subscribe::tokens_subscription;
|
||||
use mai3_pumpfun_sdk::instruction::logs_events::DexEvent;
|
||||
use mai3_pumpfun_sdk::instruction::logs_subscribe::stop_subscription;
|
||||
use mai3_pumpfun_sdk::instruction::{
|
||||
logs_events::DexEvent,
|
||||
logs_subscribe::{tokens_subscription, stop_subscription}
|
||||
};
|
||||
use anchor_client::solana_sdk::commitment_config::CommitmentConfig;
|
||||
|
||||
use std::str::FromStr;
|
||||
@@ -8,19 +9,10 @@ use tokio::signal;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
start_token_subscription().await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn start_token_subscription() -> Result<(), Box<dyn std::error::Error>> {
|
||||
println!("Starting token subscription\n");
|
||||
|
||||
let ws_url = "wss://api.mainnet-beta.solana.com";
|
||||
|
||||
// Program address
|
||||
let program_address = "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P";
|
||||
|
||||
|
||||
// Set commitment
|
||||
let commitment = CommitmentConfig::confirmed();
|
||||
|
||||
@@ -42,7 +34,6 @@ pub async fn start_token_subscription() -> Result<(), Box<dyn std::error::Error>
|
||||
// Start subscription
|
||||
let subscription = tokens_subscription(
|
||||
ws_url,
|
||||
program_address,
|
||||
commitment,
|
||||
callback
|
||||
).await.unwrap();
|
||||
|
||||
Reference in New Issue
Block a user