subscribeEntries gRPC Method - Solana gRPC
Solana gRPC is included with Scale plans and up. Learn more on our pricing page.
पैरामीटर
यह विधि किसी भी पैरामीटर को स्वीकार नहीं करती है।
रिटर्न
slot
डोरी
लोड हो रहा है...
entries
डोरी
लोड हो रहा है...
अनुरोध
1पैकेज मुख्य23आयात (4"प्रसंग"5"क्रिप्टो/टीएलएस"6"एफएमटी"7"लकड़ी का लट्ठा"8"समय"910pb "shredstream/proto"1112"google.golang.org/ grpc "13"google.golang.org/ grpc /साख"14"google.golang.org/grpc/keepalive"15)1617// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token18// For eg: QN Endpoint: https://docs-demo.solana-mainnet.quiknode.pro/abcde12345678919// endpoint will be: docs-demo.solana-mainnet.quiknode.pro:443 {443 is the port number for gRPC}20// token will be : abcde1234567892122// Each message carries the serialized bytes of a Vec<Entry> of Solana ledger entries from one slot;23// a slot is delivered as multiple messages:24// https://docs.rs/solana-entry/latest/solana_entry/entry/struct.Entry.html25//26// SubscribeEntries belongs to the shredstream.ShredstreamProxy service, not to Geyser, so it needs27// its own generated client. Save the following as shredstream.proto and generate the client with28// protoc --go_out=module=shredstream:. --go-grpc_out=module=shredstream:. shredstream.proto29//30// syntax = "proto3";31// package shredstream;32// option go_package = "shredstream/proto";33//34// message SubscribeEntriesRequest {}35//36// message Entry {37// uint64 slot = 1;38// bytes entries = 2;39// }40//41// service ShredstreamProxy {42// rpc SubscribeEntries(SubscribeEntriesRequest) returns (stream Entry) {}43// }44//45// This service does not accept compressed requests, so do not add grpc.UseCompressor to the dial options.4647var (48endpoint = "YOUR_QN_ENDPOINT:443"49token = "YOUR_TOKEN_NUMBER"50)5152var kacp = keepalive.ClientParameters{53Time: 10 * time.Second,54Timeout: time.Second,55PermitWithoutStream: true,56}5758type tokenAuth struct {59टोकन स्ट्रिंग60}6162func (t tokenAuth) GetRequestMetadata(ctx context.Context, in ...string) (map[string]string, error) {63वापस करना मानचित्र [ स्ट्रिंग ] स्ट्रिंग {64"x-token": t.token,65} , शून्य66}6768func (tokenAuth) RequireTransportSecurity() bool {69return true70}7172समारोह मुख्य ( ) {73opts := []grpc.DialOption{74grpc ( credentials.NewTLS ( & tls.Config { } ) )75grpc.WithKeepaliveParams(kacp),76grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(1024*1024*1024)),77grpc.WithPerRPCCredentials(tokenAuth{token: token}),78}7980conn, err := grpc.NewClient(endpoint, opts...)81यदि त्रुटि != शून्य {82log.Fatalf("Failed to connect: %v", err)83}84कनेक्शन स्थगित करें । बंद करें ( )8586client := pb.NewShredstreamProxyClient(conn)8788stream, err := client.SubscribeEntries(context.Background(), &pb.SubscribeEntriesRequest{})89यदि त्रुटि != शून्य {90log.Fatalf("Failed to subscribe to entries: %v", err)91}9293for {94entry, err := stream.Recv()95if err != nil {96fmt.Printf("Failed to receive entry: %v\n", err)97return98}99100fmt.Printf("Slot: %d, entries payload: %d bytes\n", entry.GetSlot(), len(entry.GetEntries()))101}102}103
1पैकेज मुख्य23आयात (4"प्रसंग"5"क्रिप्टो/टीएलएस"6"एफएमटी"7"लकड़ी का लट्ठा"8"समय"910pb "shredstream/proto"1112"google.golang.org/ grpc "13"google.golang.org/ grpc /साख"14"google.golang.org/grpc/keepalive"15)1617// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token18// For eg: QN Endpoint: https://docs-demo.solana-mainnet.quiknode.pro/abcde12345678919// endpoint will be: docs-demo.solana-mainnet.quiknode.pro:443 {443 is the port number for gRPC}20// token will be : abcde1234567892122// Each message carries the serialized bytes of a Vec<Entry> of Solana ledger entries from one slot;23// a slot is delivered as multiple messages:24// https://docs.rs/solana-entry/latest/solana_entry/entry/struct.Entry.html25//26// SubscribeEntries belongs to the shredstream.ShredstreamProxy service, not to Geyser, so it needs27// its own generated client. Save the following as shredstream.proto and generate the client with28// protoc --go_out=module=shredstream:. --go-grpc_out=module=shredstream:. shredstream.proto29//30// syntax = "proto3";31// package shredstream;32// option go_package = "shredstream/proto";33//34// message SubscribeEntriesRequest {}35//36// message Entry {37// uint64 slot = 1;38// bytes entries = 2;39// }40//41// service ShredstreamProxy {42// rpc SubscribeEntries(SubscribeEntriesRequest) returns (stream Entry) {}43// }44//45// This service does not accept compressed requests, so do not add grpc.UseCompressor to the dial options.4647var (48endpoint = "YOUR_QN_ENDPOINT:443"49token = "YOUR_TOKEN_NUMBER"50)5152var kacp = keepalive.ClientParameters{53Time: 10 * time.Second,54Timeout: time.Second,55PermitWithoutStream: true,56}5758type tokenAuth struct {59टोकन स्ट्रिंग60}6162func (t tokenAuth) GetRequestMetadata(ctx context.Context, in ...string) (map[string]string, error) {63वापस करना मानचित्र [ स्ट्रिंग ] स्ट्रिंग {64"x-token": t.token,65} , शून्य66}6768func (tokenAuth) RequireTransportSecurity() bool {69return true70}7172समारोह मुख्य ( ) {73opts := []grpc.DialOption{74grpc ( credentials.NewTLS ( & tls.Config { } ) )75grpc.WithKeepaliveParams(kacp),76grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(1024*1024*1024)),77grpc.WithPerRPCCredentials(tokenAuth{token: token}),78}7980conn, err := grpc.NewClient(endpoint, opts...)81यदि त्रुटि != शून्य {82log.Fatalf("Failed to connect: %v", err)83}84कनेक्शन स्थगित करें । बंद करें ( )8586client := pb.NewShredstreamProxyClient(conn)8788stream, err := client.SubscribeEntries(context.Background(), &pb.SubscribeEntriesRequest{})89यदि त्रुटि != शून्य {90log.Fatalf("Failed to subscribe to entries: %v", err)91}9293for {94entry, err := stream.Recv()95if err != nil {96fmt.Printf("Failed to receive entry: %v\n", err)97return98}99100fmt.Printf("Slot: %d, entries payload: %d bytes\n", entry.GetSlot(), len(entry.GetEntries()))101}102}103
1import * as grpc from "@grpc/grpc-js";2import * as protoLoader from "@grpc/proto-loader";34// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token5// For eg: QN Endpoint: https://docs-demo.solana-mainnet.quiknode.pro/abcde1234567896// endpoint will be: docs-demo.solana-mainnet.quiknode.pro:443 {443 is the port number for gRPC}7// token will be : abcde12345678989// Each message carries the serialized bytes of a Vec<Entry> of Solana ledger entries from one slot;10// a slot is delivered as multiple messages:11// https://docs.rs/solana-entry/latest/solana_entry/entry/struct.Entry.html12//13// SubscribeEntries belongs to the shredstream.ShredstreamProxy service, not to Geyser, so it is not14// exposed by the @triton-one/yellowstone-grpc client. Save the following as shredstream.proto next to15// this file and load it with @grpc/proto-loader:16//17// syntax = "proto3";18// package shredstream;19// option go_package = "shredstream/proto";20//21// message SubscribeEntriesRequest {}22//23// message Entry {24// uint64 slot = 1;25// bytes entries = 2;26// }27//28// service ShredstreamProxy {29// rpc SubscribeEntries(SubscribeEntriesRequest) returns (stream Entry) {}30// }31//32// @grpc/grpc-js takes a host:port target, so do not prefix the endpoint with https://3334const ENDPOINT = "YOUR_QN_ENDPOINT:443";35const TOKEN = "YOUR_TOKEN_NUMBER";3637const packageDefinition = protoLoader.loadSync("./shredstream.proto", {38keepCase: true,39longs: String,40enums: String,41defaults: true,42oneofs: true,43} ) ;44const shredstream = (grpc.loadPackageDefinition(packageDefinition) as any).shredstream;4546function main() {47const metadata = new grpc.Metadata();48metadata.add("x-token", TOKEN);4950const client = new shredstream.ShredstreamProxy(ENDPOINT, grpc.credentials.createSsl());51const stream = client.SubscribeEntries({}, metadata);5253stream.on("data", (entry: { slot: string; entries: Buffer }) => {54console.log(`Slot: ${entry.slot}, entries payload: ${entry.entries.length} bytes`);55});5657stream.on("error", (error: Error) => {58console.error("Stream error:", error);59});6061stream.on("end", () => {62console.log("Stream ended");63});64}6566main();67
1import * as grpc from "@grpc/grpc-js";2import * as protoLoader from "@grpc/proto-loader";34// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token5// For eg: QN Endpoint: https://docs-demo.solana-mainnet.quiknode.pro/abcde1234567896// endpoint will be: docs-demo.solana-mainnet.quiknode.pro:443 {443 is the port number for gRPC}7// token will be : abcde12345678989// Each message carries the serialized bytes of a Vec<Entry> of Solana ledger entries from one slot;10// a slot is delivered as multiple messages:11// https://docs.rs/solana-entry/latest/solana_entry/entry/struct.Entry.html12//13// SubscribeEntries belongs to the shredstream.ShredstreamProxy service, not to Geyser, so it is not14// exposed by the @triton-one/yellowstone-grpc client. Save the following as shredstream.proto next to15// this file and load it with @grpc/proto-loader:16//17// syntax = "proto3";18// package shredstream;19// option go_package = "shredstream/proto";20//21// message SubscribeEntriesRequest {}22//23// message Entry {24// uint64 slot = 1;25// bytes entries = 2;26// }27//28// service ShredstreamProxy {29// rpc SubscribeEntries(SubscribeEntriesRequest) returns (stream Entry) {}30// }31//32// @grpc/grpc-js takes a host:port target, so do not prefix the endpoint with https://3334const ENDPOINT = "YOUR_QN_ENDPOINT:443";35const TOKEN = "YOUR_TOKEN_NUMBER";3637const packageDefinition = protoLoader.loadSync("./shredstream.proto", {38keepCase: true,39longs: String,40enums: String,41defaults: true,42oneofs: true,43} ) ;44const shredstream = (grpc.loadPackageDefinition(packageDefinition) as any).shredstream;4546function main() {47const metadata = new grpc.Metadata();48metadata.add("x-token", TOKEN);4950const client = new shredstream.ShredstreamProxy(ENDPOINT, grpc.credentials.createSsl());51const stream = client.SubscribeEntries({}, metadata);5253stream.on("data", (entry: { slot: string; entries: Buffer }) => {54console.log(`Slot: ${entry.slot}, entries payload: ${entry.entries.length} bytes`);55});5657stream.on("error", (error: Error) => {58console.error("Stream error:", error);59});6061stream.on("end", () => {62console.log("Stream ended");63});64}6566main();67
अब तक कोई खाता नहीं है?
अपना बनाएँ Quicknode endpoint कुछ ही सेकंड में निर्माण शुरू करें
मुफ़्त में शुरुआत करें