Add bundle kind to `BundleValidityCache` initialization log message
This commit is contained in:
parent
087c85ec03
commit
d5a271c7a4
|
@ -13,7 +13,7 @@ mod ffi {
|
||||||
|
|
||||||
type BundleValidityCache;
|
type BundleValidityCache;
|
||||||
|
|
||||||
fn NewBundleValidityCache(bytes: usize) -> UniquePtr<BundleValidityCache>;
|
fn NewBundleValidityCache(kind: &str, bytes: usize) -> UniquePtr<BundleValidityCache>;
|
||||||
fn insert(self: Pin<&mut BundleValidityCache>, entry: [u8; 32]);
|
fn insert(self: Pin<&mut BundleValidityCache>, entry: [u8; 32]);
|
||||||
fn contains(&self, entry: &[u8; 32], erase: bool) -> bool;
|
fn contains(&self, entry: &[u8; 32], erase: bool) -> bool;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ pub(crate) struct BundleValidityCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BundleValidityCache {
|
impl BundleValidityCache {
|
||||||
fn new(personalization: &[u8; 16], cache_bytes: usize) -> Self {
|
fn new(kind: &'static str, personalization: &[u8; 16], cache_bytes: usize) -> Self {
|
||||||
// Use BLAKE2b to produce entries from bundles. It has a block size of 128 bytes,
|
// Use BLAKE2b to produce entries from bundles. It has a block size of 128 bytes,
|
||||||
// into which we put:
|
// into which we put:
|
||||||
// - 32 byte nonce
|
// - 32 byte nonce
|
||||||
|
@ -65,7 +65,7 @@ impl BundleValidityCache {
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
hasher,
|
hasher,
|
||||||
cache: ffi::NewBundleValidityCache(cache_bytes),
|
cache: ffi::NewBundleValidityCache(kind, cache_bytes),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ impl BundleValidityCache {
|
||||||
.as_bytes()
|
.as_bytes()
|
||||||
.try_into()
|
.try_into()
|
||||||
.map(CacheEntry)
|
.map(CacheEntry)
|
||||||
.unwrap()
|
.expect("BLAKE2b configured with hash length of 32 so conversion cannot fail")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn insert(&mut self, queued_entries: CacheEntries) {
|
pub(crate) fn insert(&mut self, queued_entries: CacheEntries) {
|
||||||
|
@ -117,10 +117,12 @@ static mut ORCHARD_BUNDLE_VALIDITY_CACHE: Option<RwLock<BundleValidityCache>> =
|
||||||
fn init(cache_bytes: usize) {
|
fn init(cache_bytes: usize) {
|
||||||
BUNDLE_CACHES_LOADED.call_once(|| unsafe {
|
BUNDLE_CACHES_LOADED.call_once(|| unsafe {
|
||||||
SAPLING_BUNDLE_VALIDITY_CACHE = Some(RwLock::new(BundleValidityCache::new(
|
SAPLING_BUNDLE_VALIDITY_CACHE = Some(RwLock::new(BundleValidityCache::new(
|
||||||
|
"Sapling",
|
||||||
b"SaplingVeriCache",
|
b"SaplingVeriCache",
|
||||||
cache_bytes,
|
cache_bytes,
|
||||||
)));
|
)));
|
||||||
ORCHARD_BUNDLE_VALIDITY_CACHE = Some(RwLock::new(BundleValidityCache::new(
|
ORCHARD_BUNDLE_VALIDITY_CACHE = Some(RwLock::new(BundleValidityCache::new(
|
||||||
|
"Orchard",
|
||||||
b"OrchardVeriCache",
|
b"OrchardVeriCache",
|
||||||
cache_bytes,
|
cache_bytes,
|
||||||
)));
|
)));
|
||||||
|
|
|
@ -7,12 +7,12 @@
|
||||||
|
|
||||||
namespace libzcash
|
namespace libzcash
|
||||||
{
|
{
|
||||||
std::unique_ptr<BundleValidityCache> NewBundleValidityCache(size_t nMaxCacheSize)
|
std::unique_ptr<BundleValidityCache> NewBundleValidityCache(rust::Str kind, size_t nMaxCacheSize)
|
||||||
{
|
{
|
||||||
auto cache = std::unique_ptr<BundleValidityCache>(new BundleValidityCache());
|
auto cache = std::unique_ptr<BundleValidityCache>(new BundleValidityCache());
|
||||||
size_t nElems = cache->setup_bytes(nMaxCacheSize);
|
size_t nElems = cache->setup_bytes(nMaxCacheSize);
|
||||||
LogPrintf("Using %zu MiB out of %zu requested for bundle cache, able to store %zu elements\n",
|
LogPrintf("Using %zu MiB out of %zu requested for %s bundle cache, able to store %zu elements\n",
|
||||||
(nElems * sizeof(BundleCacheEntry)) >> 20, nMaxCacheSize >> 20, nElems);
|
(nElems * sizeof(BundleCacheEntry)) >> 20, nMaxCacheSize >> 20, kind, nElems);
|
||||||
return cache;
|
return cache;
|
||||||
}
|
}
|
||||||
} // namespace libzcash
|
} // namespace libzcash
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
#include "cuckoocache.h"
|
#include "cuckoocache.h"
|
||||||
|
|
||||||
|
#include <rust/cxx.h>
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
namespace libzcash
|
namespace libzcash
|
||||||
|
@ -36,7 +38,7 @@ public:
|
||||||
|
|
||||||
typedef CuckooCache::cache<BundleCacheEntry, BundleCacheHasher> BundleValidityCache;
|
typedef CuckooCache::cache<BundleCacheEntry, BundleCacheHasher> BundleValidityCache;
|
||||||
|
|
||||||
std::unique_ptr<BundleValidityCache> NewBundleValidityCache(size_t nMaxCacheSize);
|
std::unique_ptr<BundleValidityCache> NewBundleValidityCache(rust::Str kind, size_t nMaxCacheSize);
|
||||||
} // namespace libzcash
|
} // namespace libzcash
|
||||||
|
|
||||||
template void CuckooCache::cache<libzcash::BundleCacheEntry, libzcash::BundleCacheHasher>::insert(libzcash::BundleCacheEntry e);
|
template void CuckooCache::cache<libzcash::BundleCacheEntry, libzcash::BundleCacheHasher>::insert(libzcash::BundleCacheEntry e);
|
||||||
|
|
Loading…
Reference in New Issue