Sandwich Detector
介紹
訂閱計劃
Tier 4
Tier 3
Tier 2
Tier 1
Tier 0
請求參數
参数
必選
格式
示例
备注
請求示例
# without filter
grpcurl -plaintext=false -import-path /path/to/proto -proto bscstream.proto -d '' bsc.sandwich-detector.blockrazor.me:443 bscstream.TxStreamService/SubscribeTxStream
# with filter
grpcurl -plaintext=false -import-path /path/to/proto -proto bscstream.proto -d '{"to":"0xaa..bb"}' bsc.sandwich-detector.blockrazor.me:443 bscstream.TxStreamService/SubscribeTxStreampackage main
import (
"context"
"crypto/tls"
"log"
pb "bscstream/proto/bscstream"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
)
func main() {
for {
conn, err := grpc.Dial(
"bsc.sandwich-detector.blockrazor.me:443",
grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),
grpc.WithContextDialer(func(ctx context.Context, addr string) (net.Conn, error) { //use ipv4
d := net.Dialer{DualStack: false}
return d.DialContext(ctx, "tcp4", addr)
}),
)
if err != nil {
log.Printf("Failed to connect: %v.\n", err)
continue
}
client := pb.NewTxStreamServiceClient(conn)
stream, err := client.SubscribeTxStream(context.Background(), &pb.TxFilter{
// Empty for no filter
From: "",
To: "",
Method: "",
})
if err != nil {
conn.Close()
continue
}
log.Println("Successfully subscribed to the stream.")
for {
resp, err := stream.Recv()
if err != nil {
log.Printf("Error receiving stream data: %v. Reconnecting...\n", err)
conn.Close()
break
}
log.Printf("+%v\n", resp)
}
}
}Proto
返回示例
最後更新於
這有幫助嗎?