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
9 impl::impl(size_t n_shards) : m_n_shards(n_shards) {}
10
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}
Buffer to store and retrieve byte data.
Definition buffer.hpp:15
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.
impl(size_t n_shards)
Constructor.
std::function< void(key_location_return_type)> key_location_callback_type
Callback function type for key location result.