OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
cbdc::locking_shard::interface Class Referenceabstract

Interface for a locking shard. More...

#include <interface.hpp>

Inheritance diagram for cbdc::locking_shard::interface:

Public Member Functions

 interface (std::pair< uint8_t, uint8_t > output_range)
 Constructor.
 
virtual ~interface ()=default
 
 interface ()=delete
 
 interface (const interface &)=delete
 
auto operator= (const interface &) -> interface &=delete
 
 interface (interface &&)=delete
 
auto operator= (interface &&) -> interface &=delete
 
virtual auto lock_outputs (std::vector< tx > &&txs, const hash_t &dtx_id) -> std::optional< std::vector< bool > >=0
 Attempts to lock the input hashes for the given vector of transactions.
 
virtual auto apply_outputs (std::vector< bool > &&complete_txs, const hash_t &dtx_id) -> bool=0
 Completes a previous lock operation by deleting input hashes and creating output hashes, or unlocking input hashes.
 
virtual auto hash_in_shard_range (const hash_t &h) const -> bool
 Returns whether a given hash is within the shard's range.
 
virtual auto discard_dtx (const hash_t &dtx_id) -> bool=0
 Discards any cached information about a given distributed transaction.
 
virtual void stop ()=0
 Stops the locking shard implementation from processing further commands and unblocks any pending commands.
 

Detailed Description

Interface for a locking shard.

Intended to allow for other classes to pick an implementation.

See also
locking_shard for an in-memory implementation using hashmaps
client for an implementation that connects to a remote shard over a network

Definition at line 30 of file uhs/twophase/locking_shard/interface.hpp.

Constructor & Destructor Documentation

◆ interface() [1/4]

cbdc::locking_shard::interface::interface ( std::pair< uint8_t, uint8_t > output_range)
explicit

Constructor.

Parameters
output_rangeinclusive hash prefix range the shard is responsible for managing.

Definition at line 13 of file uhs/twophase/locking_shard/interface.cpp.

◆ ~interface()

virtual cbdc::locking_shard::interface::~interface ( )
virtualdefault

◆ interface() [2/4]

cbdc::locking_shard::interface::interface ( )
delete

◆ interface() [3/4]

cbdc::locking_shard::interface::interface ( const interface & )
delete

◆ interface() [4/4]

cbdc::locking_shard::interface::interface ( interface && )
delete

Member Function Documentation

◆ apply_outputs()

virtual auto cbdc::locking_shard::interface::apply_outputs ( std::vector< bool > && complete_txs,
const hash_t & dtx_id ) -> bool
pure virtual

Completes a previous lock operation by deleting input hashes and creating output hashes, or unlocking input hashes.

Parameters
complete_txsvector of flags indicating which txs from the previous lock operation the shard should apply and which it should cancel. Must be the same size as txs from lock.
dtx_iddistributed transaction ID of the previous lock operation.
Returns
true if the apply operation succeeded.

Implemented in cbdc::locking_shard::locking_shard, and cbdc::locking_shard::rpc::client.

◆ discard_dtx()

virtual auto cbdc::locking_shard::interface::discard_dtx ( const hash_t & dtx_id) -> bool
pure virtual

Discards any cached information about a given distributed transaction.

Parameters
dtx_iddistributed transaction ID of a previous apply command.
Returns
true if the discard operation succeeded.

Implemented in cbdc::locking_shard::locking_shard, and cbdc::locking_shard::rpc::client.

◆ hash_in_shard_range()

auto cbdc::locking_shard::interface::hash_in_shard_range ( const hash_t & h) const -> bool
nodiscardvirtual

Returns whether a given hash is within the shard's range.

Parameters
hhash to check.
Returns
true if the hash is within the shard's range.

Definition at line 16 of file uhs/twophase/locking_shard/interface.cpp.

References cbdc::config::hash_in_shard_range().

Here is the call graph for this function:

◆ lock_outputs()

virtual auto cbdc::locking_shard::interface::lock_outputs ( std::vector< tx > && txs,
const hash_t & dtx_id ) -> std::optional< std::vector< bool > >
pure virtual

Attempts to lock the input hashes for the given vector of transactions.

Only considers input hashes relevant to this shard based on the shard range. The batch of transactions is a single distributed transaction, or 'dtx', referred to by a globally unique dtx ID provided by the caller.

Parameters
txslist of txs to attempt to lock.
dtx_iddistributed tx ID for lock operation.
Returns
if lock succeeds, return a vector of flags indicating which txs in the input vector had their relevant input hashes locked by the shard. Otherwise std::nullopt.

Implemented in cbdc::locking_shard::locking_shard, and cbdc::locking_shard::rpc::client.

◆ operator=() [1/2]

auto cbdc::locking_shard::interface::operator= ( const interface & ) -> interface &=delete
delete

◆ operator=() [2/2]

auto cbdc::locking_shard::interface::operator= ( interface && ) -> interface &=delete
delete

◆ stop()

virtual void cbdc::locking_shard::interface::stop ( )
pure virtual

Stops the locking shard implementation from processing further commands and unblocks any pending commands.

Implemented in cbdc::locking_shard::locking_shard, and cbdc::locking_shard::rpc::client.


The documentation for this class was generated from the following files: