Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 40 additions & 10 deletions nodes/node_balancer/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,47 @@
# Node Balancer application

# Installation
## Installation and configuration

- Prepare environment variables
- Prepare environment variables, according with `sample.env`.
- Build application

```bash
go build -o nodebalancer .
```

# Work with nodebalancer
- Generate configuration

## add-access
```bash
nodebalancer generate-config
```

- Modify configuration. Tags should NOT repeat blockchain, as it is specified in `blockchain` key. Example of configuration:

```bash
[
{
"blockchain": "ethereum",
"endpoint": "http://127.0.0.1:8545",
"tags": ["local"]
},
{
"blockchain": "ethereum",
"endpoint": "http://127.0.0.1:9585",
"tags": ["local"]
},
{
"blockchain": "ethereum",
"endpoint": "https://cool-name.quiknode.pro/y0urn0de1den1f1cat0r/",
"tags": ["external"]
}
]
```

So if with request will be specified tag `local` will be returned node with corresponding tag.

## Work with nodebalancer

### add-access

Add new access for user:

Expand All @@ -25,7 +55,7 @@ nodebalancer add-access \
--blockchain--access true
```

## delete-access
### delete-access

Delete user access:

Expand All @@ -37,7 +67,7 @@ nodebalancer delete-access \

If `access-id` not specified, all user accesses will be deleted.

## users
### users

```bash
nodebalancer users | jq .
Expand Down Expand Up @@ -67,7 +97,7 @@ This command will return a list of bugout resources of registered users to acces

`extended_methods` - boolean which allow you to call not whitelisted method to blockchain node, by default for new user this is equal to `false`

## server
### server

```bash
nodebalancer server -host 0.0.0.0 -port 8544 -healthcheck
Expand All @@ -76,17 +106,17 @@ nodebalancer server -host 0.0.0.0 -port 8544 -healthcheck
Flag `--healthcheck` will execute background process to ping-pong available nodes to keep their status and current block number.
Flag `--debug` will extend output of each request to server and healthchecks summary.

# Work with node
## Work with node

Common request to fetch block number

```bash
curl --request GET 'http://127.0.0.1:8544/nb/ethereum/jsonrpc?access_id=<access_id>&data_source=<blockchain/database>' \
curl --request POST 'http://127.0.0.1:8544/nb/ethereum/jsonrpc?access_id=<access_id>&data_source=<blockchain/database>' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc":"2.0",
"method":"eth_getBlockByNumber",
"params":["0xb71b64", false],
"params":["latest", false],
"id":1
}'
```
Expand Down
Loading