Merge pull request #640 from bugout-dev/reset-counter

Callcounter reset when 10mln
pull/642/merge
Sergei Sumarokov 2022-08-01 20:03:03 +03:00 zatwierdzone przez GitHub
commit 8421802db3
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 8 dodań i 1 usunięć

Wyświetl plik

@ -108,7 +108,12 @@ func (node *Node) UpdateNodeState(currentBlock uint64, alive bool) (callCounter
// IncreaseCallCounter increased to 1 each time node called
func (node *Node) IncreaseCallCounter() {
node.mux.Lock()
node.CallCounter++
if node.CallCounter >= NB_MAX_COUNTER_NUMBER {
log.Printf("Number of calls for node %s reached %d limit, reset the counter.", node.Endpoint, NB_MAX_COUNTER_NUMBER)
node.CallCounter = uint64(0)
} else {
node.CallCounter++
}
node.mux.Unlock()
}

Wyświetl plik

@ -30,6 +30,8 @@ var (
NB_CACHE_CLEANING_INTERVAL = time.Second * 10
NB_CACHE_ACCESS_ID_LIFETIME = int64(120)
NB_MAX_COUNTER_NUMBER = uint64(10000000)
// Client configuration
NB_CLIENT_NODE_KEEP_ALIVE = int64(5) // How long to store node in hot list for client in seconds