11# Node Balancer application
22
3- ## Installation and configuration
3+ # Installation
44
5- - Prepare environment variables, according with ` sample.env ` .
5+ - Prepare environment variables
66- Build application
77
88``` bash
99go build -o nodebalancer .
1010```
1111
12- - Generate configuration
12+ # Work with nodebalancer
1313
14- ``` bash
15- nodebalancer generate-config
16- ```
17-
18- - Modify configuration. Tags should NOT repeat blockchain, as it is specified in ` blockchain ` key. Example of configuration:
19-
20- ``` bash
21- [
22- {
23- " blockchain" : " ethereum" ,
24- " endpoint" : " http://127.0.0.1:8545" ,
25- " tags" : [" local" ]
26- },
27- {
28- " blockchain" : " ethereum" ,
29- " endpoint" : " http://127.0.0.1:9585" ,
30- " tags" : [" local" ]
31- },
32- {
33- " blockchain" : " ethereum" ,
34- " endpoint" : " https://cool-name.quiknode.pro/y0urn0de1den1f1cat0r/" ,
35- " tags" : [" external" ]
36- }
37- ]
38- ```
39-
40- So if with request will be specified tag ` local ` will be returned node with corresponding tag.
41-
42- ## Work with nodebalancer
43-
44- ** IMPORTANT** Do not use flag ` -debug ` in production.
45-
46- ### add-access
14+ ## add-access
4715
4816Add new access for user:
4917
@@ -57,7 +25,7 @@ nodebalancer add-access \
5725 --blockchain--access true
5826```
5927
60- ### delete-access
28+ ## delete-access
6129
6230Delete user access:
6331
@@ -69,7 +37,7 @@ nodebalancer delete-access \
6937
7038If ` access-id ` not specified, all user accesses will be deleted.
7139
72- ### users
40+ ## users
7341
7442``` bash
7543nodebalancer users | jq .
@@ -99,7 +67,7 @@ This command will return a list of bugout resources of registered users to acces
9967
10068` extended_methods ` - boolean which allow you to call not whitelisted method to blockchain node, by default for new user this is equal to ` false `
10169
102- ### server
70+ ## server
10371
10472``` bash
10573nodebalancer server -host 0.0.0.0 -port 8544 -healthcheck
@@ -108,17 +76,17 @@ nodebalancer server -host 0.0.0.0 -port 8544 -healthcheck
10876Flag ` --healthcheck ` will execute background process to ping-pong available nodes to keep their status and current block number.
10977Flag ` --debug ` will extend output of each request to server and healthchecks summary.
11078
111- ## Work with node
79+ # Work with node
11280
11381Common request to fetch block number
11482
11583``` bash
116- curl --request POST ' http://127.0.0.1:8544/nb/ethereum/jsonrpc?access_id=<access_id>&data_source=<blockchain/database>' \
84+ curl --request GET ' http://127.0.0.1:8544/nb/ethereum/jsonrpc?access_id=<access_id>&data_source=<blockchain/database>' \
11785 --header ' Content-Type: application/json' \
11886 --data-raw ' {
11987 "jsonrpc":"2.0",
12088 "method":"eth_getBlockByNumber",
121- "params":["latest ", false],
89+ "params":["0xb71b64 ", false],
12290 "id":1
12391 }'
12492```
@@ -129,16 +97,3 @@ For Web3 providers `access_id` and `data_source` could be specified in headers
12997--header ' x-node-balancer-data-source: <blockchain/database>'
13098--header ' x-node-balancer-access-id: <access_id>'
13199```
132-
133- Same request to fetch specific nodes using tags
134-
135- ``` bash
136- curl --request POST ' http://127.0.0.1:8544/nb/ethereum/jsonrpc?access_id=<access_id>&data_source=<blockchain/database>&tag=<specific_tag_1>&tag=<specific_tag_2>' \
137- --header ' Content-Type: application/json' \
138- --data-raw ' {
139- "jsonrpc":"2.0",
140- "method":"eth_getBlockByNumber",
141- "params":["latest", false],
142- "id":1
143- }'
144- ```
0 commit comments