LCOV - code coverage report
Current view: top level - flamenco/runtime - fd_acc_pool.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 1 0.0 %
Date: 2026-01-09 05:14:11 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_flamenco_runtime_fd_acc_pool_h
       2             : #define HEADER_fd_src_flamenco_runtime_fd_acc_pool_h
       3             : 
       4             : #include "../../util/fd_util_base.h"
       5             : #include "../types/fd_types_custom.h"
       6             : 
       7             : FD_PROTOTYPES_BEGIN
       8             : 
       9             : struct fd_acc_pool;
      10             : typedef struct fd_acc_pool fd_acc_pool_t;
      11             : 
      12             : /* We need to determine the minimum number of accounts that are required
      13             :    to be able to execute at least one transaction.  We will make the
      14             :    assumption that we can have up to MAX_TX_ACCOUNT_LOCKS (128) writable
      15             :    accounts.  We can also have 2 more writable accounts for the rollback
      16             :    fee payer and nonce.
      17             : 
      18             :    However, in the case where bundles are enabled, we will need to
      19             :    support the max number of accounts that can be in a bundle.  There
      20             :    can be up to FD_PACK_MAX_TXN_PER_BUNDLE transactions in a bundle.
      21             :    We also know that each transaction can have up to
      22             :    MAX_TX_ACCOUNT_LOCKS accounts (and 2 more for the rollback fee payer
      23             :    and nonce).  Technically, the rollback accounts don't need to be
      24             :    considered for the bundle, but currently the memory for the rollback
      25             :    accounts is allocated anyway. */
      26             : 
      27           0 : #define FD_ACC_POOL_MIN_ACCOUNT_CNT_PER_TX     (MAX_TX_ACCOUNT_LOCKS + 2UL)
      28             : #define FD_ACC_POOL_MIN_ACCOUNT_CNT_PER_BUNDLE (FD_ACC_POOL_MIN_ACCOUNT_CNT_PER_TX * FD_PACK_MAX_TXN_PER_BUNDLE)
      29             : 
      30             : /* fd_acc_pool_align returns the minimum alignment required for a
      31             :    fd_acc_pool struct. */
      32             : 
      33             : FD_FN_CONST ulong
      34             : fd_acc_pool_align( void );
      35             : 
      36             : /* fd_acc_pool_footprint returns the footprint of the fd_acc_pool
      37             :    struct for a given amount of account count. */
      38             : 
      39             : FD_FN_CONST ulong
      40             : fd_acc_pool_footprint( ulong account_cnt );
      41             : 
      42             : /* fd_acc_pool_new formats a memory region to be an fd_acc_pool_t
      43             :    object with a given amount of accounts. */
      44             : 
      45             : void *
      46             : fd_acc_pool_new( void * shmem,
      47             :                  ulong  account_cnt );
      48             : 
      49             : /* fd_acc_pool_join joins an fd_acc_pool_t object from a memory
      50             :    region.  There can be multiple valid joins for a given memory
      51             :    region corresponding to an fd_acc_pool_t object. */
      52             : 
      53             : fd_acc_pool_t *
      54             : fd_acc_pool_join( void * shmem );
      55             : 
      56             : /* fd_acc_pool_try_acquire attempts to acquire the memory for
      57             :    request_cnt accounts from the fd_acc_pool_t object.  If the requested
      58             :    number of accounts are not available, returns 1.  If successful,
      59             :    returns 0 and stores the pointers to the accounts in accounts_out.
      60             :    The caller is responsible for freeing the accounts after use via a
      61             :    call to fd_acc_pool_release.  This function is thread-safe.  For i in
      62             :    [0, request_cnt), accounts_out[i] points to the first byte of the
      63             :    returned account's buffer. */
      64             : 
      65             : int
      66             : fd_acc_pool_try_acquire( fd_acc_pool_t * acc_pool,
      67             :                          ulong           request_cnt,
      68             :                          uchar * *       accounts_out );
      69             : 
      70             : /* fd_acc_pool_acquire is the blocking and non-speculative version of
      71             :    fd_acc_pool_try_acquire.  It will keep trying to acquire the
      72             :    requested number of accounts until successful.  This function
      73             :    is thread-safe.  For i in [0, request_cnt), accounts_out[i] points to
      74             :    the first byte of the returned account's buffer. */
      75             : 
      76             : void
      77             : fd_acc_pool_acquire( fd_acc_pool_t * acc_pool,
      78             :                     ulong            request_cnt,
      79             :                     uchar * *        accounts_out );
      80             : 
      81             : /* fd_acc_pool_release releases the memory for an account back to the
      82             :    fd_acc_pool_t object.  After this is called, the account will be
      83             :    available for reuse.  This function is thread-safe. */
      84             : 
      85             : void
      86             : fd_acc_pool_release( fd_acc_pool_t * acc_pool,
      87             :                      uchar *         account );
      88             : 
      89             : FD_PROTOTYPES_END
      90             : 
      91             : #endif /* HEADER_fd_src_flamenco_runtime_fd_acc_pool_h */

Generated by: LCOV version 1.14