Skip to main content

TychoStreamBuilder

Struct TychoStreamBuilder 

Source
pub struct TychoStreamBuilder { /* private fields */ }

Implementations§

Source§

impl TychoStreamBuilder

Source

pub fn new(tycho_url: &str, chain: Chain) -> Self

Creates a new TychoStreamBuilder with the given Tycho URL and blockchain network. Initializes the builder with default values for block time and timeout based on the chain.

Source

pub fn exchange(self, name: &str, filter: ComponentFilter) -> Self

Adds an exchange and its corresponding filter to the Tycho client.

Source

pub fn block_time(self, block_time: u64) -> Self

Sets the block time for the Tycho client.

Source

pub fn timeout(self, timeout: u64) -> Self

Sets the timeout duration for network operations.

Source

pub fn startup_timeout(self, timeout: Duration) -> Self

Source

pub fn max_missed_blocks(self, max_missed_blocks: u64) -> Self

Source

pub fn websockets_retry_config(self, retry_config: &RetryConfiguration) -> Self

Source

pub fn state_synchronizer_retry_config( self, retry_config: &RetryConfiguration, ) -> Self

Source

pub fn no_state(self, no_state: bool) -> Self

Configures the client to exclude state updates from the stream.

Source

pub fn auth_key(self, auth_key: Option<String>) -> Self

Sets the API key for authenticating with the Tycho server.

Optionally you can set the TYCHO_AUTH_TOKEN env var instead. Make sure to set no_tsl to false if you do this.

Source

pub fn add_client_metadata<I, K, V>(self, metadata: I) -> Self
where I: IntoIterator<Item = (K, V)>, K: Into<String>, V: Into<String>,

Adds client-metadata entries sent to the server in the X-Tycho-Client-Metadata header.

The metadata is opaque to tycho-client; consumers supply their own keys. Accepts any iterator of key/value pairs and inserts each entry, keeping previously set metadata. An empty map sends no header. Invalid keys/values and oversized metadata are dropped with a warning at build() time, sending no header.

Values are self-reported and may surface in the server’s metrics and logs. Do not include secrets or personally identifiable information.

Source

pub fn no_tls(self, no_tls: bool) -> Self

Disables TLS/SSL for the connection, using http and ws protocols.

Source

pub fn include_tvl(self, include_tvl: bool) -> Self

Configures the client to include TVL in the stream.

If set to true, this will increase start-up time due to additional requests.

Source

pub fn disable_compression(self) -> Self

Disables compression for RPC and WebSocket communication. By default, messages are compressed using zstd.

Source

pub fn enable_partial_blocks(self) -> Self

Enables the client to receive partial block updates (flashblocks).

Source

pub fn subscription_buffer_size(self, subscription_buffer_size: usize) -> Self

Sets the number of deltas buffered for each WebSocket subscription.

The default is 128. Values outside Tokio’s supported channel range are rejected as setup errors when build is called, before any network I/O begins.

Source

pub fn max_messages(self, n: usize) -> Self

Stops the stream after emitting this many messages. Useful for testing or triggering a periodic restart after a fixed number of blocks.

Source

pub fn max_retries(self, max_retries: u64) -> Self

Overrides the maximum number of retry attempts for state synchronizer startup. The retry cooldown is derived from the chain’s block time and is not affected.

Source

pub fn blocklisted_ids(self, ids: impl IntoIterator<Item = String>) -> Self

Blocklist specific component IDs across all registered exchanges.

Blocklisted components are never tracked, regardless of TVL or other filter criteria.

Source

pub async fn build( self, ) -> Result<(JoinHandle<()>, Receiver<Result<FeedMessage<BlockHeader>, BlockSynchronizerError>>), StreamError>

Builds and starts the Tycho client, connecting to the Tycho server and setting up the synchronization of exchange components.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more