Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit 6f5e81d

Browse files
authored
transaction stream step (#787)
1 parent ac7ccb2 commit 6f5e81d

File tree

4 files changed

+47
-1
lines changed

4 files changed

+47
-1
lines changed

apps/nextra/next.config.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,12 @@ export default withBundleAnalyzer(
435435
"/en/build/indexer/indexer-sdk/documentation/connect-steps",
436436
permanent: true,
437437
},
438+
{
439+
source: "/indexer/indexer-sdk/documentation/transaction-stream",
440+
destination:
441+
"/en/build/indexer/indexer-sdk/documentation/transaction-stream",
442+
permanent: true,
443+
},
438444
{
439445
source: "/indexer/indexer-sdk/documentation/version-tracking",
440446
destination:

apps/nextra/pages/en/build/indexer/indexer-sdk/documentation/_meta.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,7 @@ export default {
1818
"version-tracking": {
1919
title: "Version Tracking",
2020
},
21+
"transaction-stream": {
22+
title: "Transaction Stream",
23+
},
2124
};

apps/nextra/pages/en/build/indexer/indexer-sdk/documentation/steps.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ To create a step with the SDK, follow these instructions:
101101

102102
The SDK implements [several common steps](https://github.com/aptos-labs/aptos-indexer-processor-sdk/tree/main/aptos-indexer-processors-sdk/sdk/src/common_steps) that you can use in your processors.
103103

104-
1. `TransactionStreamStep` provides a stream of Aptos transactions to the processor
104+
1. `TransactionStreamStep` provides a stream of Aptos transactions to the processor. Read more about it [here](./transaction-stream.mdx).
105105
2. `TimedBufferStep` buffers a batch of items and periodically polls to release the items to the next step
106106
3. `VersionTrackerStep` tracks the progress of the processor and checkpoints the processor's progress. Read more about it [here](./version-tracking.mdx).
107107
4. `OrderByVersionStep` orders transaction contextx by their starting versions. It buffers ordered these contexts and releases them at every poll interval.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
title: "Transaction Stream Step"
3+
---
4+
5+
# Transaction Stream Step
6+
7+
The `TransactionStreamStep` is a foundational component in the transaction processing pipeline. It establishes a gRPC connection with the `TransactionStream` service, fetches transactions in batches, and outputs them for further processing. This step also manages connection retries and reconnections in case of transient failures. Typically, this is the initial step in a processor, responsible for streaming transactions for downstream steps.
8+
9+
## Key Responsibilities
10+
11+
1. **Fetch Transactions**: Retrieves transaction batches from a gRPC service.
12+
2. **Manage Connections**: Handles gRPC reconnections to ensure a resilient stream.
13+
3. **Provide Metadata**: Attaches contextual information like versions and timestamps to the transactions.
14+
15+
## Struct Definition
16+
17+
The `TransactionStreamStep` struct is defined as follows:
18+
19+
```rust
20+
pub struct TransactionStreamStep
21+
where
22+
Self: Sized + Send + 'static,
23+
{
24+
transaction_stream_config: TransactionStreamConfig,
25+
pub transaction_stream: Mutex<TransactionStreamInternal>,
26+
}
27+
```
28+
29+
## How It Works
30+
31+
- The `TransactionStreamStep` connects to the gRPC `TransactionStream` service.
32+
- It continuously polls for new transactions using the `poll` method.
33+
- Each batch is wrapped in a `TransactionContext`, which includes metadata such as:
34+
- Start and end versions.
35+
- Timestamps of transactions.
36+
- Batch size in bytes.
37+
- If the connection is interrupted, it attempts to reconnect seamlessly.

0 commit comments

Comments
 (0)