public static KadHashTableConfiguration ForKadHashTable(HashTable hashTable) { KadHashTableConfiguration tableState = new KadHashTableConfiguration(); tableState.ReplicationCount = hashTable.ReplicationCount; tableState.MaxConcurrentThreads = hashTable.MaxConcurrentThreads; tableState.BucketsRefreshInSecs = hashTable.BucketsRefreshInSecs; return(tableState); }
public HashTable(Node node, IEnumerable <IPEndPoint> knownNodes, int utpPort, KadHashTableConfiguration kadHashTableConfig = null, bool useCache = false) { Owner = node; if (knownNodes != null) { foreach (var nodeEp in knownNodes) { Owner.PingAndPutNewContact(nodeEp); } } if (kadHashTableConfig != null) { ReplicationCount = kadHashTableConfig.ReplicationCount ?? ReplicationCount; MaxConcurrentThreads = kadHashTableConfig.MaxConcurrentThreads ?? MaxConcurrentThreads; BucketsRefreshInSecs = kadHashTableConfig.BucketsRefreshInSecs ?? BucketsRefreshInSecs; } _utpPort = utpPort; _ignoredIds = new SortedSet <Id>(new Id.IdComparer()); _myCancelTokenOwner = new CancellationTokenSource(); if (useCache) { QueryHistory = new InfoHashQueryHistory(); } InitTable(); }