LCOV - code coverage report
Current view: top level - funk - fd_funk.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 31 33 93.9 %
Date: 2025-07-01 05:00:49 Functions: 46 2380 1.9 %

          Line data    Source code
       1             : #ifndef HEADER_fd_src_funk_fd_funk_h
       2             : #define HEADER_fd_src_funk_fd_funk_h
       3             : 
       4             : /* Funk is a hybrid of a database and version control system designed
       5             :    for ultra high performance blockchain applications.
       6             : 
       7             :    The data model is a flat table of records.  A record is a xid/key-val
       8             :    pair and records are fast O(1) indexable by their xid/key.  xid is
       9             :    short for "transaction id" and xids have a compile time fixed size
      10             :    (e.g. 16 bytes).  keys also have a compile time fixed size (e.g.
      11             :    40 bytes).  Record values can vary in length from zero to a compile
      12             :    time maximum size.  The xid of all zeros is reserved for the "root"
      13             :    transaction described below.  Outside this, there are no
      14             :    restrictions on what a record xid, key or val can be.  Individual
      15             :    records can be created, updated, and deleted arbitrarily.  They are
      16             :    just binary data as far as funk is concerned.
      17             : 
      18             :    The maximum number of records is practically only limited by the size
      19             :    of the workspace memory backing it.  At present, each record requires
      20             :    128 bytes of metadata (this includes records that are published and
      21             :    records that are in the process of being updated).  In other words,
      22             :    about 13 GiB record metadata per hundred million records.  The
      23             :    maximum number of records that can be held by a funk instance is set
      24             :    when that it was created (given the persistent and relocatable
      25             :    properties described below though, it is straightforward to resize
      26             :    this).
      27             : 
      28             :    The transaction model is richer than what is found in a regular
      29             :    database.  A transaction is a xid-"updates to parent transaction"
      30             :    pair and transactions are fast O(1) indexable by xid.  There is no
      31             :    limitation on the number of updates in a transaction.  Updates to the
      32             :    record value are represented as the complete value record to make it
      33             :    trivial to apply cryptographic operations like hashing to all updated
      34             :    values in a transaction with file I/O, operating system calls, memory
      35             :    data marshalling overhead, etc.
      36             : 
      37             :    Like records, the maximum number of transactions in preparation is
      38             :    practically only limited by the size of the workspace memory backing
      39             :    it.  At present, a transaction requires 96 bytes of memory.  As such,
      40             :    it is practical to track a large number of forks during an extended
      41             :    period of time of consensus failure in a block chain application
      42             :    without using much workspace memory at all.  The maximum number of
      43             :    transactions that can be in preparation at any given time by a funk
      44             :    instance is set when that it was created (as before, given the
      45             :    persistent and relocatable properties described below, it is
      46             :    straightforward to resize this).
      47             : 
      48             :    That is, a transaction is a compact representation of the entire
      49             :    history of _all_ the database records up to that transaction.  We can
      50             :    trace a transaction's ancestors back to the "root" give the complete
      51             :    history of all database records up to that transaction.  The “root”
      52             :    transaction is the ancestor of all transactions.  The transaction
      53             :    history is linear from the root transaction until the "last
      54             :    published" transaction and cannot be modified.
      55             : 
      56             :    To start "preparing" a new transaction, we pick the new transaction's
      57             :    xid (ideally unique among all transactions thus far) and fork off a
      58             :    "parent" transaction.  This operation virtually clones all database
      59             :    records in the parent transaction, even if the parent itself has not
      60             :    yet been "published".  Given the above, the parent transaction can be
      61             :    the last published transaction or another in-preparation transaction.
      62             : 
      63             :    Record inserts, reads, removes take place within the context
      64             :    of a transaction, effectively isolating them to a private view of the
      65             :    world.  If a transaction is "cancelled", the changes to a record are
      66             :    harmlessly discarded.  Records in a transaction that has children
      67             :    cannot be changed ("frozen").
      68             : 
      69             :    As such, it is not possible to modify the records in transactions
      70             :    strictly before the last published transaction.  However, it is
      71             :    possible to modify the records of the last published transaction if
      72             :    there is no transactions in preparation.  This is useful, for
      73             :    example, loading up a transaction from a checkpointed state on
      74             :    startup.  A common idiom at start of a block though is to fork the
      75             :    potential transaction of that block from its parent (freezing its
      76             :    parent) and then fork a child of the potential transaction that will
      77             :    hold updates to the block that are incrementally "merged" into the
      78             :    potential transaction as block processing progresses.
      79             : 
      80             :    Critically, in-preparation transactions form a tree of dependent and
      81             :    competing histories.  This model matches blockchains, where
      82             :    speculative work can proceed on several blocks at once long before
      83             :    the blocks are finalized.  When a transaction is published, all its
      84             :    ancestors are also published, any competing histories are
      85             :    cancelled, leaving only a linear history up to the published
      86             :    transaction.  There is no practical limitation on the complexity of
      87             :    this tree.
      88             : 
      89             :    Under the hood, the database state is stored in NUMA and TLB
      90             :    optimized shared memory (i.e. fd_wksp) such that various database
      91             :    operations can be used concurrently by multiple threads distributed
      92             :    arbitrarily over multiple processes zero copy.
      93             : 
      94             :    Database operations are at algorithmic minimums with reasonably high
      95             :    performance implementations.  Most are fast O(1) time and all are
      96             :    small O(1) space (e.g. in complex transaction tree operations, there
      97             :    is no use of dynamic allocation to hold temporaries and no use of
      98             :    recursion to bound stack utilization at trivial levels).  Further,
      99             :    there are no explicit operating system calls and, given a well
     100             :    optimized workspace (i.e. the wksp pages fit within a core's TLBs) no
     101             :    implicit operating system calls.  Critical operations (e.g. those
     102             :    that actually might impact transaction history) are fortified against
     103             :    memory corruption (e.g. robust against DoS attack by corrupting
     104             :    transaction metadata to create loops in transaction trees or going
     105             :    out of bounds in memory).  Outside of record values, all memory used
     106             :    is preallocated.  And record values are O(1) lockfree concurrent
     107             :    allocated via fd_alloc using the same wksp as funk (the
     108             :    implementation is structured in layers that are straightforward to
     109             :    retarget for particular applications as might be necessary).
     110             : 
     111             :    The shared memory used by a funk instance is within a workspace such
     112             :    that it is also persistent and remotely inspectable.  For example, a
     113             :    process attached to a funk instance can be terminated and a new
     114             :    process can resume exactly where the original process left off
     115             :    instantly (e.g. no file I/O).  Or a real-time monitor could be
     116             :    visualizing the ongoing activity in a database non-invasively (e.g.
     117             :    forks in flight, records updated by forks, etc).  Or an auxiliary
     118             :    process could be lazily and non-invasively writing all published
     119             :    records to permanent storage in the background in parallel with
     120             :    on-going operations.
     121             : 
     122             :    The records are further stored in the workspace memory relocatably.
     123             :    For example, workspace memory could just be committed to a persistent
     124             :    memory as is (or backed by NVMe or such directly), copied to a
     125             :    different host, and processes on the new host could resume (indeed,
     126             :    though it wouldn't be space efficient, the shared memory region is
     127             :    usable as is as an on-disk checkpoint file).  Or the workspace could
     128             :    be resized and what not to handle large needs than when the database
     129             :    was initially created and it all "just works".
     130             : 
     131             :    Limited concurrent (multithreaded) access is supported. As a
     132             :    general rule, transaction level operations
     133             :    (e.g. fd_funk_txn_cancel and fd_funk_txn_publish) have to be
     134             :    single-threaded. In this case, no other access is allowed at the
     135             :    same time. Purely record level operations are thread safe and can
     136             :    be arbitrarily interleaved across multiple cpus. Specifically,
     137             :    these are:
     138             :      fd_funk_rec_query_try
     139             :      fd_funk_rec_query_test
     140             :      fd_funk_rec_query_try_global
     141             :      fd_funk_rec_prepare
     142             :      fd_funk_rec_publish
     143             :      fd_funk_rec_cancel
     144             :      fd_funk_rec_remove
     145             : */
     146             : 
     147             : //#include "fd_funk_base.h" /* Includes ../util/fd_util.h */
     148             : //#include "fd_funk_txn.h"  /* Includes fd_funk_base.h */
     149             : //#include "fd_funk_rec.h"  /* Includes fd_funk_txn.h */
     150             : #include "fd_funk_val.h"    /* Includes fd_funk_rec.h */
     151             : 
     152             : /* FD_FUNK_ALIGN describe the alignment needed
     153             :    for a funk.  ALIGN should be a positive integer power of 2.
     154             :    The footprint is dynamic depending on map sizes. */
     155             : 
     156         147 : #define FD_FUNK_ALIGN (4096UL)
     157             : 
     158             : /* The details of a fd_funk_shmem_private are exposed here to facilitate
     159             :    inlining various operations. */
     160             : 
     161          42 : #define FD_FUNK_MAGIC (0xf17eda2ce7fc2c02UL) /* firedancer funk version 2 */
     162             : 
     163             : struct __attribute__((aligned(FD_FUNK_ALIGN))) fd_funk_shmem_private {
     164             : 
     165             :   /* Metadata */
     166             : 
     167             :   ulong magic;      /* ==FD_FUNK_MAGIC */
     168             :   ulong funk_gaddr; /* wksp gaddr of this in the backing wksp, non-zero gaddr */
     169             :   ulong wksp_tag;   /* Tag to use for wksp allocations, positive */
     170             :   ulong seed;       /* Seed for various hashing function used under the hood, arbitrary */
     171             :   ulong cycle_tag;  /* Next cycle_tag to use, used internally for various data integrity checks */
     172             : 
     173             :   /* The funk transaction map stores the details about transactions
     174             :      in preparation and their relationships to each other.  This is a
     175             :      fd_map_chain_para/fd_pool_para and more details are given in
     176             :      fd_funk_txn.h
     177             : 
     178             :      txn_max is the maximum number of transactions that can be in
     179             :      preparation.  Due to the use of compressed map indices to reduce
     180             :      workspace memory footprint required, txn_max is at most
     181             :      FD_FUNK_TXN_IDX_NULL (currently ~4B).  This should be more than
     182             :      ample for anticipated uses cases ... e.g. every single validator in
     183             :      a pool of tens of thousands Solana validator had its own fork and
     184             :      with no consensus ever being achieved, a funk with txn_max at the
     185             :      limits of a compressed index will be chug along for days to weeks
     186             :      before running out of indexing space.  But if ever needing to
     187             :      support more, it is straightforward to change the code to not use
     188             :      index compression.  Then, a funk (with a planet sized workspace
     189             :      backing it) would survive a similar scenario for millions of years.
     190             :      Presumably, if such a situation arose, in the weeks to eons while
     191             :      there was consensus, somebody would notice and care enough to
     192             :      intervene (if not it is probably irrelevant to the real world
     193             :      anyway).
     194             : 
     195             :      txn_map_gaddr is the wksp gaddr of the fd_funk_txn_map_t used by
     196             :      this funk.
     197             : 
     198             :      child_{head,tail}_cidx are compressed txn map indices.  After
     199             :      decompression, they give the txn map index of the {oldest,youngest}
     200             :      child of funk (i.e. an in-preparation transaction whose parent
     201             :      transaction id is last_publish).  FD_FUNK_TXN_IDX_NULL indicates
     202             :      the funk is childless.  Thus, if head/tail is FD_FUNK_TXN_IDX_NULL,
     203             :      tail/head will be too. funk is "frozen" if it has children.
     204             : 
     205             :      last_publish is the ID of the last published transaction.  It will
     206             :      be the root transaction if no transactions have been published.
     207             :      Will be the root transaction immediately after construction. */
     208             : 
     209             :   ulong txn_max;         /* In [0,FD_FUNK_TXN_IDX_NULL] */
     210             :   ulong txn_map_gaddr;   /* Non-zero wksp gaddr with tag wksp_tag
     211             :                             seed   ==fd_funk_txn_map_seed   (txn_map)
     212             :                             txn_max==fd_funk_txn_map_key_max(txn_map) */
     213             :   ulong txn_pool_gaddr;
     214             :   ulong txn_ele_gaddr;
     215             : 
     216             :   uint  child_head_cidx; /* After decompression, in [0,txn_max) or FD_FUNK_TXN_IDX_NULL, FD_FUNK_TXN_IDX_NULL if txn_max 0 */
     217             :   uint  child_tail_cidx; /* " */
     218             : 
     219             :   /* Padding to FD_FUNK_TXN_XID_ALIGN here */
     220             : 
     221             :   fd_funk_txn_xid_t root[1];         /* Always equal to the root transaction */
     222             :   fd_funk_txn_xid_t last_publish[1]; /* Root transaction immediately after construction, not root thereafter */
     223             : 
     224             :   /* The funk record map stores the details about all the records in
     225             :      the funk, including all those in the last published transaction and
     226             :      all those getting updated in an in-preparation translation.  This
     227             :      is a fd_map_chain_para/fd_pool_para and more details are given in
     228             :      fd_funk_rec.h
     229             : 
     230             :      rec_max is the maximum number of records that can exist in this
     231             :      funk.
     232             : 
     233             :      rec_map_gaddr is the wksp gaddr of the fd_funk_rec_map_t used by
     234             :      this funk. */
     235             : 
     236             :   uint rec_max;
     237             :   ulong rec_map_gaddr; /* Non-zero wksp gaddr with tag wksp_tag
     238             :                           seed   ==fd_funk_rec_map_seed   (rec_map)
     239             :                           rec_max==fd_funk_rec_map_key_max(rec_map) */
     240             :   ulong rec_pool_gaddr;
     241             :   ulong rec_ele_gaddr;
     242             :   uint rec_head_idx;  /* Record map index of the first record, FD_FUNK_REC_IDX_NULL if none (from oldest to youngest) */
     243             :   uint rec_tail_idx;  /* "                       last          " */
     244             : 
     245             :   /* The funk alloc is used for allocating wksp resources for record
     246             :      values.  This is a fd_alloc and more details are given in
     247             :      fd_funk_val.h.  Allocations from this allocator will be tagged with
     248             :      wksp_tag and operations on this allocator will use concurrency
     249             :      group 0.
     250             : 
     251             :      TODO: Consider letting user just pass a join of alloc (and maybe
     252             :      the cgroup_idx to give the funk), inferring the wksp, cgroup from
     253             :      that and allocating exclusively from that? */
     254             : 
     255             :   ulong alloc_gaddr; /* Non-zero wksp gaddr with tag wksp tag */
     256             :   uchar lock;        /* lock for synchronizing modifications to funk object */
     257             : 
     258             :   /* Padding to FD_FUNK_ALIGN here */
     259             : };
     260             : 
     261             : /* The details of a fd_funk_private are exposed here to facilitate
     262             :    inlining various operations. */
     263             : 
     264             : #define FD_FUNK_JOIN_ALIGN 64
     265             : 
     266             : struct __attribute__((aligned(FD_FUNK_JOIN_ALIGN))) fd_funk_private {
     267             : 
     268             :   fd_funk_shmem_t *  shmem;
     269             : 
     270             :   fd_funk_txn_map_t  txn_map[1];
     271             :   fd_funk_txn_pool_t txn_pool[1];
     272             : 
     273             :   fd_funk_rec_map_t  rec_map[1];
     274             :   fd_funk_rec_pool_t rec_pool[1];
     275             : 
     276             :   fd_wksp_t *  wksp;
     277             :   fd_alloc_t * alloc;
     278             : 
     279             : };
     280             : 
     281             : FD_PROTOTYPES_BEGIN
     282             : 
     283             : /* Constructors */
     284             : 
     285             : /* fd_funk_align return FD_FUNK_ALIGN. */
     286             : 
     287             : FD_FN_CONST ulong
     288             : fd_funk_align( void );
     289             : 
     290             : /* fd_funk_footprint returns the size need for funk and all
     291             :    auxiliary data structures. Note that only record valus are
     292             :    allocated dynamically. */
     293             : 
     294             : FD_FN_CONST ulong
     295             : fd_funk_footprint( ulong txn_max,
     296             :                    ulong rec_max );
     297             : 
     298             : /* fd_funk_new formats an unused wksp allocation with the appropriate
     299             :    alignment and footprint as a funk.  Caller is not joined on return.
     300             :    Returns shmem on success and NULL on failure (shmem NULL, shmem
     301             :    misaligned, zero wksp_tag, shmem is not backed by a wksp ...  logs
     302             :    details).  A workspace can be used by multiple funks concurrently.
     303             :    They will dynamically share the underlying workspace (along with any
     304             :    other non-funk usage) but will otherwise act as completely separate
     305             :    non-conflicting funks.  To help with various diagnostics, garbage
     306             :    collection and what not, all allocations to the underlying wksp are
     307             :    tagged with the given tag (positive).  Ideally, the tag used here
     308             :    should be distinct from all other tags used by this workspace but
     309             :    this is not required. */
     310             : 
     311             : void *
     312             : fd_funk_new( void * shmem,
     313             :              ulong  wksp_tag,
     314             :              ulong  seed,
     315             :              ulong  txn_max,
     316             :              ulong  rec_max );
     317             : 
     318             : /* fd_funk_join joins the caller to a funk instance.  ljoin points to a
     319             :    fd_funk_t compatible memory region in the caller's address space,
     320             :    shfunk points to the first byte of the memory region backing the funk
     321             :    in the caller's address space.  Returns an handle to the caller's
     322             :    local join on success (join has ownership of the ljoin region) and
     323             :    NULL on failure (NULL ljoin, NULL shfunk, misaligned shfunk, shfunk
     324             :    is not backed by a wksp, bad magic, ... logs details).  Every
     325             :    successful join should have a matching leave.  The lifetime of the
     326             :    join is until the matching leave or the thread group is terminated
     327             :    (joins are local to a thread group). */
     328             : 
     329             : fd_funk_t *
     330             : fd_funk_join( fd_funk_t * ljoin,
     331             :               void *      shfunk );
     332             : 
     333             : /* fd_funk_leave leaves a funk join.  Returns the memory region used for
     334             :    join on success (caller has ownership on return and the caller is no
     335             :    longer joined) and NULL on failure (logs details).  Sets *opt_shfunk
     336             :    a pointer to the funk shm region if opt_shfunk!=NULL. */
     337             : 
     338             : void *
     339             : fd_funk_leave( fd_funk_t * funk,
     340             :                void **     opt_shfunk );
     341             : 
     342             : /* fd_funk_delete unformats a wksp allocation used as a funk
     343             :    (additionally frees all wksp allocations used by that funk).  Assumes
     344             :    nobody is or will be joined to the funk.  Returns shmem on success
     345             :    and NULL on failure (logs details).  Reasons for failure include
     346             :    shfunk is NULL, misaligned shfunk, shfunk is not backed by a
     347             :    workspace, etc. */
     348             : 
     349             : void *
     350             : fd_funk_delete( void * shfunk );
     351             : 
     352             : /* fd_funk_delete_fast is an optimized verison of fd_funk_delete.
     353             :    Unlike fd_funk_delete, makes an additional assumption that this funk
     354             :    was created with a wksp_tag (see fd_funk_new) that is distinct from
     355             :    all other tags in the workspace.  Also unlike fd_funk_delete, frees
     356             :    wksp allocation backing the funk instance itself.
     357             : 
     358             :    WARNING: Using this function frees all wksp allocations matching the
     359             :    funk's wksp_tag. */
     360             : 
     361             : void
     362             : fd_funk_delete_fast( void * shfunk );
     363             : 
     364             : /* Accessors */
     365             : 
     366             : /* fd_funk_wksp returns the local join to the wksp backing the funk.
     367             :    The lifetime of the returned pointer is at least as long as the
     368             :    lifetime of the local join.  Assumes funk is a current local join. */
     369             : 
     370    23749272 : FD_FN_PURE static inline fd_wksp_t * fd_funk_wksp( fd_funk_t const * funk ) { return funk->wksp; }
     371             : 
     372             : /* fd_funk_wksp_tag returns the workspace allocation tag used by the
     373             :    funk for its wksp allocations.  Will be positive.  Assumes funk is a
     374             :    current local join. */
     375             : 
     376          15 : FD_FN_PURE static inline ulong fd_funk_wksp_tag( fd_funk_t * funk ) { return funk->shmem->wksp_tag; }
     377             : 
     378             : /* fd_funk_seed returns the hash seed used by the funk for various hash
     379             :    functions.  Arbitrary value.  Assumes funk is a current local join.
     380             :    TODO: consider renaming hash_seed? */
     381             : 
     382           3 : FD_FN_PURE static inline ulong fd_funk_seed( fd_funk_t * funk ) { return funk->shmem->seed; }
     383             : 
     384             : /* fd_funk_txn_max returns maximum number of in-preparations the funk
     385             :    can support.  Assumes funk is a current local join.  Return in
     386             :    [0,FD_FUNK_TXN_IDX_NULL]. */
     387             : 
     388           3 : FD_FN_PURE static inline ulong fd_funk_txn_max( fd_funk_t * funk ) { return funk->txn_pool->ele_max; }
     389             : 
     390             : /* fd_funk_txn_map returns the funk's transaction map join. This
     391             :    join can copied by value and is generally stored as a stack variable. */
     392             : 
     393    20582280 : FD_FN_PURE static inline fd_funk_txn_map_t * fd_funk_txn_map( fd_funk_t * funk ) { return funk->txn_map; }
     394             : 
     395             : /* fd_funk_txn_pool returns the funk's transaction pool join. This
     396             :    join can copied by value and is generally stored as a stack variable. */
     397             : 
     398      102009 : FD_FN_PURE static inline fd_funk_txn_pool_t * fd_funk_txn_pool( fd_funk_t * funk ) { return funk->txn_pool; }
     399             : 
     400             : /* fd_funk_last_publish_child_{head,tail} returns a pointer in the
     401             :    caller's address space to {oldest,young} transaction child of root, NULL if
     402             :    funk is childless.  All pointers are in the caller's address space.
     403             :    These are all a fast O(1) but not fortified against memory data
     404             :    corruption. */
     405             : 
     406             : FD_FN_PURE static inline fd_funk_txn_t *
     407             : fd_funk_last_publish_child_head( fd_funk_t *          funk,
     408        5538 :                                  fd_funk_txn_pool_t * pool ) {
     409        5538 :   ulong idx = fd_funk_txn_idx( funk->shmem->child_head_cidx );
     410        5538 :   if( fd_funk_txn_idx_is_null( idx ) ) return NULL; /* TODO: Consider branchless? */
     411        5538 :   return pool->ele + idx;
     412        5538 : }
     413             : 
     414             : FD_FN_PURE static inline fd_funk_txn_t *
     415             : fd_funk_last_publish_child_tail( fd_funk_t *          funk,
     416        5538 :                                  fd_funk_txn_pool_t * pool ) {
     417        5538 :   ulong idx = fd_funk_txn_idx( funk->shmem->child_tail_cidx );
     418        5538 :   if( fd_funk_txn_idx_is_null( idx ) ) return NULL; /* TODO: Consider branchless? */
     419        5538 :   return pool->ele + idx;
     420        5538 : }
     421             : 
     422             : /* fd_funk_root returns a pointer in the caller's address space to the
     423             :    transaction id of the root transaction.  Assumes funk is a current
     424             :    local join.  Lifetime of the returned pointer is the lifetime of the
     425             :    current local join.  The value at this pointer will always be the
     426             :    root transaction id. */
     427             : 
     428      206560 : FD_FN_CONST static inline fd_funk_txn_xid_t const * fd_funk_root( fd_funk_t * funk ) { return funk->shmem->root; }
     429             : 
     430             : /* fd_funk_last_publish returns a pointer in the caller's address space
     431             :    to transaction id of the last published transaction.  Assumes funk is
     432             :    a current local join.  Lifetime of the returned pointer is the
     433             :    lifetime of the current local join.  The value at this pointer will
     434             :    be constant until the next transaction is published. */
     435             : 
     436     3145734 : FD_FN_CONST static inline fd_funk_txn_xid_t const * fd_funk_last_publish( fd_funk_t * funk ) { return funk->shmem->last_publish; }
     437             : 
     438             : /* fd_funk_is_frozen returns 1 if the records of the last published
     439             :    transaction are frozen (i.e. the funk has children) and 0 otherwise
     440             :    (i.e. the funk is childless).  Assumes funk is a current local join. */
     441             : 
     442             : FD_FN_PURE static inline int
     443   189318884 : fd_funk_last_publish_is_frozen( fd_funk_t const * funk ) {
     444   189318884 :   return fd_funk_txn_idx( funk->shmem->child_head_cidx )!=FD_FUNK_TXN_IDX_NULL;
     445   189318884 : }
     446             : 
     447             : /* fd_funk_rec_max returns maximum number of records that can be held
     448             :    in the funk.  This includes both records of the last published
     449             :    transaction and records for transactions that are in-flight. */
     450             : 
     451           0 : FD_FN_PURE static inline ulong fd_funk_rec_max( fd_funk_t * funk ) { return funk->rec_pool->ele_max; }
     452             : 
     453             : /* fd_funk_rec_map returns the funk's record map join. This
     454             :    join can copied by value and is generally stored as a stack variable. */
     455             : 
     456    23740431 : FD_FN_PURE static inline fd_funk_rec_map_t * fd_funk_rec_map( fd_funk_t * funk ) { return funk->rec_map; }
     457             : 
     458             : /* fd_funk_rec_pool returns the funk's record pool join. This
     459             :    join can copied by value and is generally stored as a stack variable. */
     460             : 
     461           0 : FD_FN_PURE static inline fd_funk_rec_pool_t * fd_funk_rec_pool( fd_funk_t * funk ) { return funk->rec_pool; }
     462             : 
     463             : /* fd_funk_alloc returns a pointer in the caller's address space to
     464             :    the funk's allocator. */
     465             : 
     466    23444997 : FD_FN_PURE static inline fd_alloc_t * fd_funk_alloc( fd_funk_t * funk ) { return funk->alloc; }
     467             : 
     468             : /* fd_funk_rec_is_full returns 1 if no more records can be allocated
     469             :    and 0 otherwise. */
     470             : 
     471             : static inline int
     472    24223038 : fd_funk_rec_is_full( fd_funk_t * funk ) {
     473    24223038 :   return fd_funk_rec_pool_is_empty( funk->rec_pool );
     474    24223038 : }
     475             : 
     476             : /* fd_funk_txn_is_full returns true if the transaction map is
     477             :    full. No more in-preparation transactions are allowed. */
     478             : 
     479             : static inline int
     480      836880 : fd_funk_txn_is_full( fd_funk_t * funk ) {
     481      836880 :   return fd_funk_txn_pool_is_empty( funk->txn_pool );
     482      836880 : }
     483             : 
     484             : /* Misc */
     485             : 
     486             : /* fd_funk_verify verifies the integrity of funk.  Returns
     487             :    FD_FUNK_SUCCESS if funk appears to be intact and FD_FUNK_ERR_INVAL
     488             :    otherwise (logs details).  Assumes funk is a current local join (NULL
     489             :    returns FD_FUNK_ERR_INVAL and logs details.) */
     490             : 
     491             : int
     492             : fd_funk_verify( fd_funk_t * funk );
     493             : 
     494             : FD_PROTOTYPES_END
     495             : 
     496             : #endif /* HEADER_fd_src_funk_fd_funk_h */

Generated by: LCOV version 1.14