From e8d45b213dd8e638eaa6db530767e5cd07bd407e Mon Sep 17 00:00:00 2001 From: gagliardetto Date: Sat, 23 Oct 2021 13:04:01 +0200 Subject: [PATCH] WS: add defer ws client close --- rpc/ws/examples/accountSubscribe/accountSubscribe.go | 1 + rpc/ws/examples/logsSubscribe/logsSubscribe.go | 1 + rpc/ws/examples/programSubscribe/programSubscribe.go | 1 + rpc/ws/examples/rootSubscribe/rootSubscribe.go | 1 + rpc/ws/examples/signatureSubscribe/signatureSubscribe.go | 1 + rpc/ws/examples/slotSubscribe/slotSubscribe.go | 1 + rpc/ws/examples/voteSubscribe/voteSubscribe.go | 1 + 7 files changed, 7 insertions(+) diff --git a/rpc/ws/examples/accountSubscribe/accountSubscribe.go b/rpc/ws/examples/accountSubscribe/accountSubscribe.go index 24a21586..61193df3 100644 --- a/rpc/ws/examples/accountSubscribe/accountSubscribe.go +++ b/rpc/ws/examples/accountSubscribe/accountSubscribe.go @@ -28,6 +28,7 @@ func main() { if err != nil { panic(err) } + defer client.Close() program := solana.MustPublicKeyFromBase58("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin") // serum { diff --git a/rpc/ws/examples/logsSubscribe/logsSubscribe.go b/rpc/ws/examples/logsSubscribe/logsSubscribe.go index 931996b0..3a32e3d8 100644 --- a/rpc/ws/examples/logsSubscribe/logsSubscribe.go +++ b/rpc/ws/examples/logsSubscribe/logsSubscribe.go @@ -28,6 +28,7 @@ func main() { if err != nil { panic(err) } + defer client.Close() program := solana.MustPublicKeyFromBase58("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin") // serum { diff --git a/rpc/ws/examples/programSubscribe/programSubscribe.go b/rpc/ws/examples/programSubscribe/programSubscribe.go index eda462be..2a54e77f 100644 --- a/rpc/ws/examples/programSubscribe/programSubscribe.go +++ b/rpc/ws/examples/programSubscribe/programSubscribe.go @@ -29,6 +29,7 @@ func main() { panic(err) } program := solana.MustPublicKeyFromBase58("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA") // token + defer client.Close() sub, err := client.ProgramSubscribeWithOpts( program, diff --git a/rpc/ws/examples/rootSubscribe/rootSubscribe.go b/rpc/ws/examples/rootSubscribe/rootSubscribe.go index d11c6b27..87ccd962 100644 --- a/rpc/ws/examples/rootSubscribe/rootSubscribe.go +++ b/rpc/ws/examples/rootSubscribe/rootSubscribe.go @@ -27,6 +27,7 @@ func main() { if err != nil { panic(err) } + defer client.Close() sub, err := client.RootSubscribe() if err != nil { diff --git a/rpc/ws/examples/signatureSubscribe/signatureSubscribe.go b/rpc/ws/examples/signatureSubscribe/signatureSubscribe.go index 59f247c3..6a2f40b2 100644 --- a/rpc/ws/examples/signatureSubscribe/signatureSubscribe.go +++ b/rpc/ws/examples/signatureSubscribe/signatureSubscribe.go @@ -28,6 +28,7 @@ func main() { if err != nil { panic(err) } + defer client.Close() txSig := solana.MustSignatureFromBase58("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") diff --git a/rpc/ws/examples/slotSubscribe/slotSubscribe.go b/rpc/ws/examples/slotSubscribe/slotSubscribe.go index 91e06224..1da17f87 100644 --- a/rpc/ws/examples/slotSubscribe/slotSubscribe.go +++ b/rpc/ws/examples/slotSubscribe/slotSubscribe.go @@ -27,6 +27,7 @@ func main() { if err != nil { panic(err) } + defer client.Close() sub, err := client.SlotSubscribe() if err != nil { diff --git a/rpc/ws/examples/voteSubscribe/voteSubscribe.go b/rpc/ws/examples/voteSubscribe/voteSubscribe.go index d218c4ad..e5f8d7cf 100644 --- a/rpc/ws/examples/voteSubscribe/voteSubscribe.go +++ b/rpc/ws/examples/voteSubscribe/voteSubscribe.go @@ -27,6 +27,7 @@ func main() { if err != nil { panic(err) } + defer client.Close() // NOTE: this subscription must be enabled by the node you're connecting to. // This subscription is disabled by default.