> ## Documentation Index
> Fetch the complete documentation index at: https://www.helius.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# LaserStream 클라이언트

> 자동 재생 및 데이터 손실 없는 gRPC 스트리밍을 위한 고성능 SDK

## 연결 끊김 시 자동 재생

LaserStream 클라이언트는 슬롯 번호로 스트리밍 위치를 지속적으로 추적합니다. 네트워크 문제, 서버 유지 보수 또는 기타 원인으로 연결이 끊어지면 클라이언트는 자동으로 다시 연결되고 마지막으로 처리된 슬롯부터 스트리밍을 재개합니다. 데이터를 잃지 않고, 트랜잭션을 놓치지 않으며, 재연결 로직을 작성할 필요가 없습니다.

## JavaScript/TypeScript 클라이언트

<Warning>
  **JavaScript 앱에 LaserStream SDK로 전환하는 것을 강력히 권장합니다.** 현재 Yellowstone gRPC 클라이언트를 사용하는 경우 스트림 지연 및 시간이 지남에 따라 누적되는 성능 병목 현상이 발생할 수 있습니다. LaserStream 클라이언트의 성능 여유는 네트워크와 함께 앱이 확장되도록 보장하며 이러한 문제를 완전히 제거합니다.
</Warning>

[JavaScript 클라이언트](https://github.com/helius-labs/laserstream-sdk/tree/main/javascript)는 네이티브 Rust 바인딩을 사용하여 1.3GB/s 처리량을 달성합니다. 이는 최대 30MB/s에 불과한 Yellowstone gRPC JavaScript 클라이언트보다 40배 이상 빠릅니다.

**4배 빠른 이벤트 감지**: Rust 기반 아키텍처 덕분에 LaserStream JavaScript 클라이언트는 Yellowstone 클라이언트보다 4배 빠르게 이벤트를 수신 및 처리하여 응용 프로그램이 이벤트를 먼저 볼 수 있는 중요한 경쟁력을 제공합니다.

고대역폭 구독에서는 Yellowstone 클라이언트가 시간이 지남에 따라 누적되는 지연을 경험합니다. LaserStream은 데이터 양에 관계없이 일관된 저지연 스트리밍을 유지합니다.

### 설치

<CodeGroup>
  ```bash npm theme={"system"}
  npm install helius-laserstream
  ```

  ```bash yarn theme={"system"}
  yarn add helius-laserstream
  ```

  ```bash pnpm theme={"system"}
  pnpm add helius-laserstream
  ```
</CodeGroup>

<Tip>
  [Helius Dashboard](https://dashboard.helius.dev/laserstream)에서 LaserStream을 시작하세요. 메인넷은 비즈니스 또는 프로페셔널 플랜이 필요하며, Devnet은 개발자 및 그 이상에서 사용할 수 있습니다. 자세한 내용은 [플랜 및 가격](/docs/ko/billing/plans)을 참조하세요.
</Tip>

### 빠른 시작

```typescript [expandable] theme={"system"}
import { subscribe, CommitmentLevel, LaserstreamConfig, SubscribeRequest } from 'helius-laserstream';

async function streamTransactions() {
  const config: LaserstreamConfig = {
    apiKey: 'YOUR_API_KEY',
    endpoint: 'https://laserstream-mainnet-ewr.helius-rpc.com',
  };

  const request: SubscribeRequest = {
    transactions: {
      "jupiter-filter": { // user-defined label for this filter
        accountInclude: ['JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4'], // Jupiter Program
        accountExclude: [],
        accountRequired: [],
        vote: false,
        failed: false
      }
    },
    commitment: CommitmentLevel.CONFIRMED,
    accounts: {},
    slots: {},
    transactionsStatus: {},
    blocks: {},
    blocksMeta: {},
    entry: {},
    accountsDataSlice: []
  };

  // The SDK handles reconnection and replay automatically
  await subscribe(config, request, 
    async (data) => {
      console.log('New transaction:', data);
    }, 
    async (error) => {
      console.error('Error:', error);
    }
  );
}

streamTransactions().catch(console.error);
```

0.4.0부터 JavaScript 클라이언트는 [쿠쿠 필터를 통한 압축 계정 필터링](/docs/ko/laserstream/cuckoo-filters)을 지원하여 대규모 명시적 공개키 목록을 보내는 대신 단일 구독에서 수십만 개의 계정을 추적할 수 있습니다.

### 안정성 비교

| 기능        | LaserStream | Yellowstone  |
| --------- | ----------- | ------------ |
| 자동 재생     | ✅ 내장        | ❌ 수동 구현 필요   |
| 누적 지연     | ❌ 없음        | ✅ 고대역폭에서 발생  |
| 데이터 손실 보호 | ✅ 자동        | ❌ 응용 프로그램 책임 |
| 재연결       | ✅ 매끄러운      | ❌ 내장 지원 없음   |

## Rust 클라이언트

[Rust 클라이언트](https://github.com/helius-labs/laserstream-sdk/tree/main/rust)는 최대 제어가 필요한 응용 프로그램을 위해 제로 복사 디직렬화 및 네이티브 성능을 제공합니다.

0.2.0부터 Rust 클라이언트는 [쿠쿠 필터를 통한 압축 계정 필터링](/docs/ko/laserstream/cuckoo-filters)을 지원하여 단일 구독에서 수십만 개의 계정을 추적할 수 있습니다. (JavaScript SDK 0.4.0+에서도 사용 가능.)

### 설치

```toml theme={"system"}
[dependencies]
helius-laserstream = "0.2"
tokio = { version = "1", features = ["full"] }
```

### 빠른 시작

```rust [expandable] theme={"system"}
use futures::StreamExt;
use helius_laserstream::{
    grpc::{CommitmentLevel, SubscribeRequest, SubscribeRequestFilterTransactions},
    subscribe, LaserstreamConfig,
};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = LaserstreamConfig {
        api_key: "YOUR_API_KEY".to_string(),
        endpoint: "https://laserstream-mainnet-ewr.helius-rpc.com".to_string(),
        ..Default::default()
    };

    let mut request = SubscribeRequest::default();
    request.transactions.insert(
        "jupiter-filter".to_string(),
        SubscribeRequestFilterTransactions {
            vote: Some(false),
            failed: Some(false),
            account_include: vec!["JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4".to_string()],
            ..Default::default()
        },
    );
    request.commitment = Some(CommitmentLevel::Confirmed as i32);

    let (stream, _handle) = subscribe(config, request);
    tokio::pin!(stream);

    while let Some(result) = stream.next().await {
        match result {
            Ok(data) => println!("New transaction: {:?}", data),
            Err(e) => eprintln!("Error: {:?}", e),
        }
    }

    Ok(())
}
```

## Go 클라이언트

[Go 클라이언트](https://github.com/helius-labs/laserstream-sdk/tree/main/go)는 관용적인 Go 인터페이스를 제공합니다.

### 설치

```bash theme={"system"}
go get github.com/helius-labs/laserstream-sdk/go
```

### 빠른 시작

```go [expandable] theme={"system"}
package main

import (
    "log"
    "os"
    "os/signal"
    "syscall"

    laserstream "github.com/helius-labs/laserstream-sdk/go"
    pb "github.com/helius-labs/laserstream-sdk/go/proto"
)

func main() {
    clientConfig := laserstream.LaserstreamConfig{
        APIKey:   "YOUR_API_KEY",
        Endpoint: "https://laserstream-mainnet-ewr.helius-rpc.com",
    }

    voteFilter := false
    failedFilter := false
    commitment := pb.CommitmentLevel_CONFIRMED

    subscriptionRequest := &pb.SubscribeRequest{
        Transactions: map[string]*pb.SubscribeRequestFilterTransactions{
            "jupiter-filter": {
                Vote:           &voteFilter,
                Failed:         &failedFilter,
                AccountInclude: []string{"JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4"},
            },
        },
        Commitment: &commitment,
    }

    client := laserstream.NewClient(clientConfig)

    dataCallback := func(data *pb.SubscribeUpdate) {
        log.Printf("New transaction: %+v\n", data)
    }
    errorCallback := func(err error) {
        log.Printf("Error: %v", err)
    }

    if err := client.Subscribe(subscriptionRequest, dataCallback, errorCallback); err != nil {
        log.Fatalf("Failed to subscribe: %v", err)
    }

    sigChan := make(chan os.Signal, 1)
    signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
    <-sigChan
    client.Close()
}
```

## Yellowstone에서 LaserStream으로 마이그레이션해야 하는 이유

Yellowstone 클라이언트는 Solana가 확장됨에 따라 악화될 중요한 제한사항에 직면합니다:

1. **성능 병목 현상**: Yellowstone JavaScript 클라이언트는 최대 30MB/s로, 고처리량 응용 프로그램에는 불충분합니다
2. **누적 지연**: 고대역폭 구독에서 시간이 지남에 따라 지연이 누적됩니다
3. **수동 재생**: 재연결 및 재생 로직을 직접 구현해야 합니다
4. **데이터 손실 위험**: 내장된 재생이 없으면 네트워크 중단 시 트랜잭션이 누락됩니다

**LaserStream은 오늘날 이러한 문제를 해결합니다**. 40배 더 나은 성능, 자동 재생 및 데이터 손실이 없는 보장을 통해 Solana가 발전함에 따라 LaserStream으로의 마이그레이션은 응용 프로그램의 경쟁력을 보장합니다.
