OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
directory/impl.cpp
Go to the documentation of this file.
1
// Copyright (c) 2021 MIT Digital Currency Initiative,
2
// Federal Reserve Bank of Boston
3
// Distributed under the MIT software license, see the accompanying
4
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6
#include "
impl.hpp
"
7
8
namespace
cbdc::parsec::directory
{
9
impl::impl
(
size_t
n_shards) : m_n_shards(n_shards) {}
10
11
auto
impl::key_location
(
runtime_locking_shard::key_type
key,
12
key_location_callback_type
result_callback)
13
->
bool
{
14
auto
key_hash = m_siphash(key);
15
// NOTE: using modulo creates a small bias from a true
16
// uniform distribution
17
auto
shard = key_hash % m_n_shards;
18
result_callback(shard);
19
return
true
;
20
}
21
}
cbdc::buffer
Buffer to store and retrieve byte data.
Definition
buffer.hpp:15
cbdc::parsec::directory::impl::key_location
auto key_location(runtime_locking_shard::key_type key, key_location_callback_type result_callback) -> bool override
Returns the shard ID responsible for the given key.
Definition
directory/impl.cpp:11
cbdc::parsec::directory::impl::impl
impl(size_t n_shards)
Constructor.
Definition
directory/impl.cpp:9
cbdc::parsec::directory::interface::key_location_callback_type
std::function< void(key_location_return_type)> key_location_callback_type
Callback function type for key location result.
Definition
parsec/directory/interface.hpp:26
impl.hpp
cbdc::parsec::directory
Definition
directory/impl.cpp:8
src
parsec
directory
impl.cpp
Generated by
1.12.0