Updated README.md and debug logs

pull/741/head
kompotkot 2023-01-16 11:08:18 +00:00
rodzic b4ca416e1c
commit 87d034f48a
3 zmienionych plików z 24 dodań i 5 usunięć

Wyświetl plik

@ -41,6 +41,8 @@ So if with request will be specified tag `local` will be returned node with corr
## Work with nodebalancer
**IMPORTANT** Do not use flag `-debug` in production.
### add-access
Add new access for user:
@ -127,3 +129,16 @@ For Web3 providers `access_id` and `data_source` could be specified in headers
--header 'x-node-balancer-data-source: <blockchain/database>'
--header 'x-node-balancer-access-id: <access_id>'
```
Same request to fetch specific nodes using tags
```bash
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>' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc":"2.0",
"method":"eth_getBlockByNumber",
"params":["latest", false],
"id":1
}'
```

Wyświetl plik

@ -105,7 +105,7 @@ func initCacheCleaning() {
case <-t.C:
removedAccessIds, totalAccessIds := accessIdCache.Cleanup()
if stateCLI.enableDebugFlag {
log.Printf("Removed %d elements from access id cache", removedAccessIds)
log.Printf("[DEBUG] Removed %d elements from access id cache", removedAccessIds)
}
log.Printf("Elements in access id cache: %d", totalAccessIds)
}
@ -241,7 +241,7 @@ func logMiddleware(next http.Handler) http.Handler {
if stateCLI.enableDebugFlag {
if r.URL.RawQuery != "" {
logStr += fmt.Sprintf(" %s", r.URL.RawQuery)
logStr += fmt.Sprintf(" [DEBUG] %s", r.URL.RawQuery)
}
accessID := extractAccessID(r)
if accessID != "" {
@ -269,20 +269,20 @@ func accessMiddleware(next http.Handler) http.Handler {
// If access id does not belong to internal crawlers, then check cache or find it in Bugout resources
if accessID == NB_CONTROLLER_ACCESS_ID {
if stateCLI.enableDebugFlag {
log.Printf("Access id belongs to internal crawlers")
log.Printf("[DEBUG] Access id belongs to internal crawlers")
}
currentClientAccess = internalCrawlersAccess
currentClientAccess.dataSource = dataSource
} else if accessIdCache.FindAccessIdInCache(accessID) != "" {
if stateCLI.enableDebugFlag {
log.Printf("Access id found in cache")
log.Printf("[DEBUG] Access id found in cache")
}
currentClientAccess = accessIdCache.accessIds[accessID]
currentClientAccess.dataSource = dataSource
accessIdCache.UpdateAccessIdAtCache(accessID, dataSource)
} else {
if stateCLI.enableDebugFlag {
log.Printf("New access id, looking at Brood resources")
log.Printf("[DEBUG] New access id, looking at Brood resources")
}
resources, err := bugoutClient.Brood.GetResources(
NB_CONTROLLER_TOKEN,

Wyświetl plik

@ -114,6 +114,10 @@ func lbJSONRPCHandler(w http.ResponseWriter, r *http.Request, blockchain string,
cpool.AddClientNode(currentClientAccess.AccessID, node)
}
if stateCLI.enableDebugFlag {
log.Printf("[DEBUG] Used node with endpoint: %s, call counter equals: %d", node.Endpoint, node.CallCounter)
}
switch {
case currentClientAccess.dataSource == "blockchain":
if currentClientAccess.BlockchainAccess == false {