pub fn new(
        chain_id: ChainId,
        node_addr: tendermint_rpc::Url,
        rt: Arc<TokioRuntime>,
    ) -> Result<(Self, channel::Receiver<EventBatch>), Error> {
        let (tx, rx) = channel::unbounded();

        let ws_addr = node_addr.clone();
        let (websocket_client, websocket_driver) = rt.block_on(async move {
            WebSocketClient::new(ws_addr.clone())
                .await
                .map_err(|e| Kind::Websocket(ws_addr).context(e))
        })?;

        let websocket_driver_handle = rt.spawn(websocket_driver.run());

        // TODO: move them to config file(?)
        let event_queries = vec![Query::from(EventType::Tx), Query::from(EventType::NewBlock)];

        let monitor = Self {
            rt,
            chain_id,
            websocket_client,
            websocket_driver_handle,
            event_queries,
            tx_batch: tx,
            node_addr,
            subscriptions: Box::new(futures::stream::empty()),
        };

        Ok((monitor, rx))
    }
/// Create an event monitor, and connect to a node
Create an event monitor, and connect to a node
Create an event monitor and connect to a node
pub fn new(
        chain_id: ChainId,
        node_addr: tendermint_rpc::Url,
        rt: Arc<TokioRuntime>,
    ) -> Result<(Self, channel::Receiver<EventBatch>), Error> {
        let (tx, rx) = channel::unbounded();
        let ws_addr = node_addr.clone();
        let (websocket_client, websocket_driver) = rt.block_on(async move {
            WebSocketClient::new(ws_addr.clone())
                .await
                .map_err(|e| Kind::Websocket(ws_addr).context(e))
        })?;
        let websocket_driver_handle = rt.spawn(websocket_driver.run());
        // TODO: move them to config file(?)
        let event_queries = vec![Query::from(EventType::Tx), Query::from(EventType::NewBlock)];
        let monitor = Self {
            rt,
            chain_id,
            websocket_client,
            websocket_driver_handle,
            event_queries,
            tx_batch: tx,
            node_addr,
            subscriptions: Box::new(futures::stream::empty()),
        };
        Ok((monitor, rx))
    }
pub fn new ( chain_id : ChainId , node_addr : tendermint_rpc :: Url , rt : Arc < TokioRuntime > , ) -> Result < ( Self , channel :: Receiver < EventBatch > ) , Error > { let ( tx , rx ) = channel :: unbounded ( ) ; let ws_addr = node_addr . clone ( ) ; let ( websocket_client , websocket_driver ) = rt . block_on ( async move { WebSocketClient :: new ( ws_addr . clone ( ) ) . await . map_err ( | e | Kind :: Websocket ( ws_addr ) . context ( e ) ) } ) ? ; let websocket_driver_handle = rt . spawn ( websocket_driver . run ( ) ) ; // TODO: move them to config file(?) let event_queries = vec ! [ Query from ( EventType Tx ) Query from ( EventType NewBlock ) ] ; let monitor = Self { rt , chain_id , websocket_client , websocket_driver_handle , event_queries , tx_batch : tx , node_addr , subscriptions : Box :: new ( futures :: stream :: empty ( ) ) , } ; Ok ( ( monitor , rx ) ) }
Create an event monitor, and connect to a node
Create an event monitor and connect to a node
chain_id
ChainId
node_addr
tendermint_rpc::Url
rt
Arc<TokioRuntime>
chain_id
ChainId
node_addr
tendermint_rpc::Url
rt
Arc<TokioRuntime>