Max known nodes configurable
This commit is contained in:
parent
26eb54a82e
commit
b9d60f8b41
|
@ -23,6 +23,9 @@ BMConfigDefaults = {
|
|||
"storage": "sqlite",
|
||||
"acceptmismatch": False,
|
||||
},
|
||||
"knownnodes": {
|
||||
"maxnodes": 20000,
|
||||
},
|
||||
"zlib": {
|
||||
'maxsize': 1048576
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import pickle
|
||||
import threading
|
||||
|
||||
from bmconfigparser import BMConfigParser
|
||||
import state
|
||||
|
||||
knownNodesLock = threading.Lock()
|
||||
knownNodes = {}
|
||||
|
||||
knownNodesMax = 20000
|
||||
knownNodesTrimAmount = 2000
|
||||
|
||||
def saveKnownNodes(dirName = None):
|
||||
|
@ -17,7 +17,7 @@ def saveKnownNodes(dirName = None):
|
|||
pickle.dump(knownNodes, output)
|
||||
|
||||
def trimKnownNodes(recAddrStream = 1):
|
||||
if len(knownNodes[recAddrStream]) < knownNodesMax:
|
||||
if len(knownNodes[recAddrStream]) < BMConfigParser().get("knownnodes", "maxnodes"):
|
||||
return
|
||||
with knownNodesLock:
|
||||
oldestList = sorted(knownNodes[recAddrStream], key=knownNodes[recAddrStream].get)[:knownNodesTrimAmount]
|
||||
|
|
Loading…
Reference in New Issue
Block a user