diff --git a/.changeset/heavy-hats-sit.md b/.changeset/heavy-hats-sit.md deleted file mode 100644 index 2412dbd..0000000 --- a/.changeset/heavy-hats-sit.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@chainlink/wsrpc": patch ---- - -Update dependencies diff --git a/.changeset/ten-boxes-move.md b/.changeset/ten-boxes-move.md deleted file mode 100644 index e65f940..0000000 --- a/.changeset/ten-boxes-move.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@chainlink/wsrpc": patch ---- - -Remove deprecated usages of protogen Annotate method diff --git a/CHANGELOG.md b/CHANGELOG.md index 79ff784..90f5660 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,25 +1,33 @@ # 0.3.0 +## 0.8.1 + +### Patch Changes + +- [#53](https://github.com/smartcontractkit/wsrpc/pull/53) [`94c9fea`](https://github.com/smartcontractkit/wsrpc/commit/94c9fead7991b59a3ec1010c4392672bcfc84f00) Thanks [@erikburt](https://github.com/erikburt)! - Update dependencies + +- [#53](https://github.com/smartcontractkit/wsrpc/pull/53) [`94c9fea`](https://github.com/smartcontractkit/wsrpc/commit/94c9fead7991b59a3ec1010c4392672bcfc84f00) Thanks [@erikburt](https://github.com/erikburt)! - Remove deprecated usages of protogen Annotate method + * Use context to cancel a blocking `Dial`. ``` // With timeout - ctx := context.Background() - ctx, cancel := context.WithTimeout(ctx, 5*time.Second) - defer cancel() - conn, err := wsrpc.DialWithContext(ctx, "127.0.0.1:1338", - wsrpc.WithTransportCreds(privKey, serverPubKey), - wsrpc.WithBlock(), - ) + ctx := context.Background() + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + conn, err := wsrpc.DialWithContext(ctx, "127.0.0.1:1338", + wsrpc.WithTransportCreds(privKey, serverPubKey), + wsrpc.WithBlock(), + ) // Manual cancel ctx := context.Background() - ctx, cancel := context.WithCancel(ctx) - go func() { + ctx, cancel := context.WithCancel(ctx) + go func() { conn, err := wsrpc.DialWithContext(ctx, "127.0.0.1:1338", - wsrpc.WithTransportCreds(privKey, serverPubKey), - wsrpc.WithBlock(), - )}() + wsrpc.WithTransportCreds(privKey, serverPubKey), + wsrpc.WithBlock(), + )}() // Something causes the need to cancel. cancel() @@ -29,37 +37,39 @@ established or dropped. You can then retrieve the latest list of keys ``` - go func() { - for { - notifyCh := s.GetConnectionNotifyChan() - <-notifyCh - - fmt.Println("Connected to:", s.GetConnectedPeerPublicKeys()) - } - }() + go func() { + for { + notifyCh := s.GetConnectionNotifyChan() + <-notifyCh + + fmt.Println("Connected to:", s.GetConnectedPeerPublicKeys()) + } + }() ``` # 0.2.0 -* Replace metadata public key context with with a peer context. +- Replace metadata public key context with with a peer context. **Extracting a public key** + ``` // Previously - pubKey, ok := metadata.PublicKeyFromContext(ctx) - if !ok { - return nil, errors.New("could not extract public key") - } + pubKey, ok := metadata.PublicKeyFromContext(ctx) + if !ok { + return nil, errors.New("could not extract public key") + } // Now p, ok := peer.FromContext(ctx) - if !ok { - return nil, errors.New("could not extract peer information") - } + if !ok { + return nil, errors.New("could not extract peer information") + } pubKey := p.PublicKey ``` **Making a server side RPC call** + ``` // Previously ctx := context.WithValue(context.Background(), metadata.PublicKeyCtxKey, pubKey) @@ -69,14 +79,15 @@ ctx := peer.NewCallContext(context.Background(), pubKey) res, err := c.Gnip(ctx, &pb.GnipRequest{Body: "Gnip"}) ``` -* Add a `WithBlock` DialOption which blocks the caller of Dial until the underlying connection is up. + +- Add a `WithBlock` DialOption which blocks the caller of Dial until the underlying connection is up. # 0.1.1 ## Changed -* Supress logging until we can implement a configurable logging solution. +- Supress logging until we can implement a configurable logging solution. # 0.1.0 -Initial release \ No newline at end of file +Initial release diff --git a/package.json b/package.json index eed627e..010726f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@chainlink/wsrpc", - "version": "0.8.0", + "version": "0.8.1", "description": "Bi-directional communication channel using mTLS and web sockets.", "main": "index.js", "private": true,