Improving network map and CRL caches (#866)

* Improving network map and CRL caches

* Addressing review comments
This commit is contained in:
Michal Kit 2018-05-22 13:04:16 +01:00 committed by GitHub
parent d651ad9bb3
commit 2b2b856a17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -75,7 +75,15 @@ class NetworkMapWebService(private val nodeInfoStorage: NodeInfoStorage,
.softValues()
.build(nodeInfoStorage::getNodeInfo)
private val networkMaps: NetworkMaps? get() = networkMapCache[true]
private val networkMaps: NetworkMaps?
get() {
if (networkMapCache[true]?.publicNetworkMap == null) {
// Refresh cache every time the public network map is NULL.
networkMapCache.refresh(true)
}
return networkMapCache[true]
}
private val currentNodeInfoHashes: Set<SecureHash> get() = networkMaps?.allNodeInfoHashes ?: emptySet()
private val currentNetworkParameters: NetworkParameters? get() = networkMaps?.publicNetworkMap?.networkParameters?.networkParameters