Skip to content

Commit

Permalink
Fix: README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Dec 7, 2021
1 parent 65c27aa commit bb64304
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions README.md
Expand Up @@ -56,6 +56,22 @@ Simple Tezos RPC API wrapper.
import "github.com/dipdup-net/go-lib/node"

rpc := node.NewNodeRPC(url, node.WithTimeout(timeout))

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

// example with context
constants, err := rpc.Constants(node.WithContext(ctx))
if err != nil {
panic(err)
}

// example without context
constants, err := rpc.Constants()
if err != nil {
panic(err)
}

```

### `database`
Expand Down Expand Up @@ -105,7 +121,7 @@ There are 2 default implementations of `Database` interface:

There is method `Wait` which waiting until database connection will be established.

Exaple of usage:
Example of usage:

```go
ctx, cancel := context.WithCancel(context.Background())
Expand All @@ -115,6 +131,7 @@ db := database.NewPgGo()
if err := db.Connect(ctx, cfg); err != nil {
panic(err)
}
defer db.Close()

database.Wait(ctx, db, 5*time.Second)

Expand Down Expand Up @@ -212,21 +229,13 @@ func main() {
Example usage of the API wrapper:

```go
package main

import (
"log"
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

"github.com/dipdup-net/go-lib/tzkt/api"
)
tzkt := api.New("url here")

func main() {
tzkt := api.New("url here")

head, err := tzkt.GetHead()
if err != nil {
log.Panic(err)
}
log.Println(head)
head, err := tzkt.GetHead(ctx)
if err != nil {
log.Panic(err)
}
```

0 comments on commit bb64304

Please sign in to comment.