package main
import (
"context"
"errors"
"fmt"
"io"
"log"
"github.com/orbitflare/orbitflare-sdk-go/geyser"
)
func main() {
client, err := geyser.NewBuilder().
URL("http://ny.rpc.orbitflare.com:10000").
FallbackURL("http://fra.rpc.orbitflare.com:10000").
Build()
if err != nil {
log.Fatal(err)
}
defer client.Close()
request := geyser.NewSubscribeRequestBuilder().
Transactions("pumpfun", geyser.NewTransactionFilter().
Vote(false).
Failed(false).
AccountInclude("6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P")).
Slots("slots", geyser.NewSlotFilter().FilterByCommitment(true)).
Commitment(geyser.Confirmed).
Build()
stream := client.Subscribe(request)
defer stream.Close()
ctx := context.Background()
var count int
fmt.Println("streaming...")
for {
update, err := stream.Next(ctx)
if errors.Is(err, io.EOF) {
return
}
if err != nil {
log.Fatal(err)
}
switch {
case update.GetTransaction() != nil:
count++
tx := update.GetTransaction()
fmt.Printf("#%d slot=%d\n", count, tx.GetSlot())
case update.GetSlot() != nil:
s := update.GetSlot()
fmt.Printf("slot %d (%s)\n", s.GetSlot(), s.GetStatus())
}
}
}