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-10-13 04:42:14 Functions: 44 2193 2.0 %

          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             : */
     145             : 
     146             : //#include "fd_funk_base.h" /* Includes ../util/fd_util.h */
     147             : //#include "fd_funk_txn.h"  /* Includes fd_funk_base.h */
     148             : //#include "fd_funk_rec.h"  /* Includes fd_funk_txn.h */
     149             : #include "fd_funk_val.h"    /* Includes fd_funk_rec.h */
     150             : 
     151             : /* FD_FUNK_ALIGN describe the alignment needed
     152             :    for a funk.  ALIGN should be a positive integer power of 2.
     153             :    The footprint is dynamic depending on map sizes. */
     154             : 
     155         183 : #define FD_FUNK_ALIGN (4096UL)
     156             : 
     157             : /* The details of a fd_funk_shmem_private are exposed here to facilitate
     158             :    inlining various operations. */
     159             : 
     160          48 : #define FD_FUNK_MAGIC (0xf17eda2ce7fc2c02UL) /* firedancer funk version 2 */
     161             : 
     162             : struct __attribute__((aligned(FD_FUNK_ALIGN))) fd_funk_shmem_private {
     163             : 
     164             :   /* Metadata */
     165             : 
     166             :   ulong magic;      /* ==FD_FUNK_MAGIC */
     167             :   ulong funk_gaddr; /* wksp gaddr of this in the backing wksp, non-zero gaddr */
     168             :   ulong wksp_tag;   /* Tag to use for wksp allocations, positive */
     169             :   ulong seed;       /* Seed for various hashing function used under the hood, arbitrary */
     170             :   ulong cycle_tag;  /* Next cycle_tag to use, used internally for various data integrity checks */
     171             : 
     172             :   /* The funk transaction map stores the details about transactions
     173             :      in preparation and their relationships to each other.  This is a
     174             :      fd_map_chain_para/fd_pool_para and more details are given in
     175             :      fd_funk_txn.h
     176             : 
     177             :      txn_max is the maximum number of transactions that can be in
     178             :      preparation.  Due to the use of compressed map indices to reduce
     179             :      workspace memory footprint required, txn_max is at most
     180             :      FD_FUNK_TXN_IDX_NULL (currently ~4B).  This should be more than
     181             :      ample for anticipated uses cases ... e.g. every single validator in
     182             :      a pool of tens of thousands Solana validator had its own fork and
     183             :      with no consensus ever being achieved, a funk with txn_max at the
     184             :      limits of a compressed index will be chug along for days to weeks
     185             :      before running out of indexing space.  But if ever needing to
     186             :      support more, it is straightforward to change the code to not use
     187             :      index compression.  Then, a funk (with a planet sized workspace
     188             :      backing it) would survive a similar scenario for millions of years.
     189             :      Presumably, if such a situation arose, in the weeks to eons while
     190             :      there was consensus, somebody would notice and care enough to
     191             :      intervene (if not it is probably irrelevant to the real world
     192             :      anyway).
     193             : 
     194             :      txn_map_gaddr is the wksp gaddr of the fd_funk_txn_map_t used by
     195             :      this funk.
     196             : 
     197             :      child_{head,tail}_cidx are compressed txn map indices.  After
     198             :      decompression, they give the txn map index of the {oldest,youngest}
     199             :      child of funk (i.e. an in-preparation transaction whose parent
     200             :      transaction id is last_publish).  FD_FUNK_TXN_IDX_NULL indicates
     201             :      the funk is childless.  Thus, if head/tail is FD_FUNK_TXN_IDX_NULL,
     202             :      tail/head will be too. funk is "frozen" if it has children.
     203             : 
     204             :      last_publish is the ID of the last published transaction.  It will
     205             :      be the root transaction if no transactions have been published.
     206             :      Will be the root transaction immediately after construction. */
     207             : 
     208             :   ulong txn_max;         /* In [0,FD_FUNK_TXN_IDX_NULL] */
     209             :   ulong txn_map_gaddr;   /* Non-zero wksp gaddr with tag wksp_tag
     210             :                             seed   ==fd_funk_txn_map_seed   (txn_map)
     211             :                             txn_max==fd_funk_txn_map_key_max(txn_map) */
     212             :   ulong txn_pool_gaddr;
     213             :   ulong txn_ele_gaddr;
     214             : 
     215             :   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 */
     216             :   uint  child_tail_cidx; /* " */
     217             : 
     218             :   /* Padding to FD_FUNK_TXN_XID_ALIGN here */
     219             : 
     220             :   fd_funk_txn_xid_t root[1];         /* Always equal to the root transaction */
     221             :   fd_funk_txn_xid_t last_publish[1]; /* Root transaction immediately after construction, not root thereafter */
     222             : 
     223             :   /* The funk record map stores the details about all the records in
     224             :      the funk, including all those in the last published transaction and
     225             :      all those getting updated in an in-preparation translation.  This
     226             :      is a fd_map_chain_para/fd_pool_para and more details are given in
     227             :      fd_funk_rec.h
     228             : 
     229             :      rec_max is the maximum number of records that can exist in this
     230             :      funk.
     231             : 
     232             :      rec_map_gaddr is the wksp gaddr of the fd_funk_rec_map_t used by
     233             :      this funk. */
     234             : 
     235             :   uint rec_max;
     236             :   ulong rec_map_gaddr; /* Non-zero wksp gaddr with tag wksp_tag
     237             :                           seed   ==fd_funk_rec_map_seed   (rec_map)
     238             :                           rec_max==fd_funk_rec_map_key_max(rec_map) */
     239             :   ulong rec_pool_gaddr;
     240             :   ulong rec_ele_gaddr;
     241             : 
     242             :   /* The funk alloc is used for allocating wksp resources for record
     243             :      values.  This is a fd_alloc and more details are given in
     244             :      fd_funk_val.h.  Allocations from this allocator will be tagged with
     245             :      wksp_tag and operations on this allocator will use concurrency
     246             :      group 0.
     247             : 
     248             :      TODO: Consider letting user just pass a join of alloc (and maybe
     249             :      the cgroup_idx to give the funk), inferring the wksp, cgroup from
     250             :      that and allocating exclusively from that? */
     251             : 
     252             :   ulong alloc_gaddr; /* Non-zero wksp gaddr with tag wksp tag */
     253             : 
     254             :   /* Padding to FD_FUNK_ALIGN here */
     255             : };
     256             : 
     257             : /* The details of a fd_funk_private are exposed here to facilitate
     258             :    inlining various operations. */
     259             : 
     260             : #define FD_FUNK_JOIN_ALIGN 64
     261             : 
     262             : struct __attribute__((aligned(FD_FUNK_JOIN_ALIGN))) fd_funk_private {
     263             : 
     264             :   fd_funk_shmem_t *  shmem;
     265             : 
     266             :   fd_funk_txn_map_t  txn_map[1];
     267             :   fd_funk_txn_pool_t txn_pool[1];
     268             : 
     269             :   fd_funk_rec_map_t  rec_map[1];
     270             :   fd_funk_rec_pool_t rec_pool[1];
     271             : 
     272             :   fd_wksp_t *  wksp;
     273             :   fd_alloc_t * alloc;
     274             : 
     275             : };
     276             : 
     277             : FD_PROTOTYPES_BEGIN
     278             : 
     279             : /* Constructors */
     280             : 
     281             : /* fd_funk_align return FD_FUNK_ALIGN. */
     282             : 
     283             : FD_FN_CONST ulong
     284             : fd_funk_align( void );
     285             : 
     286             : /* fd_funk_footprint returns the size need for funk and all
     287             :    auxiliary data structures. Note that only record valus are
     288             :    allocated dynamically. */
     289             : 
     290             : FD_FN_CONST ulong
     291             : fd_funk_footprint( ulong txn_max,
     292             :                    ulong rec_max );
     293             : 
     294             : /* fd_funk_new formats an unused wksp allocation with the appropriate
     295             :    alignment and footprint as a funk.  Caller is not joined on return.
     296             :    Returns shmem on success and NULL on failure (shmem NULL, shmem
     297             :    misaligned, zero wksp_tag, shmem is not backed by a wksp ...  logs
     298             :    details).  A workspace can be used by multiple funks concurrently.
     299             :    They will dynamically share the underlying workspace (along with any
     300             :    other non-funk usage) but will otherwise act as completely separate
     301             :    non-conflicting funks.  To help with various diagnostics, garbage
     302             :    collection and what not, all allocations to the underlying wksp are
     303             :    tagged with the given tag (positive).  Ideally, the tag used here
     304             :    should be distinct from all other tags used by this workspace but
     305             :    this is not required. */
     306             : 
     307             : void *
     308             : fd_funk_new( void * shmem,
     309             :              ulong  wksp_tag,
     310             :              ulong  seed,
     311             :              ulong  txn_max,
     312             :              ulong  rec_max );
     313             : 
     314             : /* fd_funk_join joins the caller to a funk instance.  ljoin points to a
     315             :    fd_funk_t compatible memory region in the caller's address space,
     316             :    shfunk points to the first byte of the memory region backing the funk
     317             :    in the caller's address space.  Returns an handle to the caller's
     318             :    local join on success (join has ownership of the ljoin region) and
     319             :    NULL on failure (NULL ljoin, NULL shfunk, misaligned shfunk, shfunk
     320             :    is not backed by a wksp, bad magic, ... logs details).  Every
     321             :    successful join should have a matching leave.  The lifetime of the
     322             :    join is until the matching leave or the thread group is terminated
     323             :    (joins are local to a thread group). */
     324             : 
     325             : fd_funk_t *
     326             : fd_funk_join( fd_funk_t * ljoin,
     327             :               void *      shfunk );
     328             : 
     329             : /* fd_funk_leave leaves a funk join.  Returns the memory region used for
     330             :    join on success (caller has ownership on return and the caller is no
     331             :    longer joined) and NULL on failure (logs details).  Sets *opt_shfunk
     332             :    a pointer to the funk shm region if opt_shfunk!=NULL. */
     333             : 
     334             : void *
     335             : fd_funk_leave( fd_funk_t * funk,
     336             :                void **     opt_shfunk );
     337             : 
     338             : /* fd_funk_delete unformats a wksp allocation used as a funk
     339             :    (additionally frees all wksp allocations used by that funk).  Assumes
     340             :    nobody is or will be joined to the funk.  Returns shmem on success
     341             :    and NULL on failure (logs details).  Reasons for failure include
     342             :    shfunk is NULL, misaligned shfunk, shfunk is not backed by a
     343             :    workspace, etc. */
     344             : 
     345             : void *
     346             : fd_funk_delete( void * shfunk );
     347             : 
     348             : /* fd_funk_delete_fast is an optimized verison of fd_funk_delete.
     349             :    Unlike fd_funk_delete, makes an additional assumption that this funk
     350             :    was created with a wksp_tag (see fd_funk_new) that is distinct from
     351             :    all other tags in the workspace.  Also unlike fd_funk_delete, frees
     352             :    wksp allocation backing the funk instance itself.
     353             : 
     354             :    WARNING: Using this function frees all wksp allocations matching the
     355             :    funk's wksp_tag. */
     356             : 
     357             : void
     358             : fd_funk_delete_fast( void * shfunk );
     359             : 
     360             : /* Accessors */
     361             : 
     362             : /* fd_funk_wksp returns the local join to the wksp backing the funk.
     363             :    The lifetime of the returned pointer is at least as long as the
     364             :    lifetime of the local join.  Assumes funk is a current local join. */
     365             : 
     366        2280 : FD_FN_PURE static inline fd_wksp_t * fd_funk_wksp( fd_funk_t const * funk ) { return funk->wksp; }
     367             : 
     368             : /* fd_funk_wksp_tag returns the workspace allocation tag used by the
     369             :    funk for its wksp allocations.  Will be positive.  Assumes funk is a
     370             :    current local join. */
     371             : 
     372          15 : FD_FN_PURE static inline ulong fd_funk_wksp_tag( fd_funk_t * funk ) { return funk->shmem->wksp_tag; }
     373             : 
     374             : /* fd_funk_seed returns the hash seed used by the funk for various hash
     375             :    functions.  Arbitrary value.  Assumes funk is a current local join.
     376             :    TODO: consider renaming hash_seed? */
     377             : 
     378           3 : FD_FN_PURE static inline ulong fd_funk_seed( fd_funk_t * funk ) { return funk->shmem->seed; }
     379             : 
     380             : /* fd_funk_txn_max returns maximum number of in-preparations the funk
     381             :    can support.  Assumes funk is a current local join.  Return in
     382             :    [0,FD_FUNK_TXN_IDX_NULL]. */
     383             : 
     384           3 : FD_FN_PURE static inline ulong fd_funk_txn_max( fd_funk_t * funk ) { return funk->txn_pool->ele_max; }
     385             : 
     386             : /* fd_funk_txn_map returns the funk's transaction map join. This
     387             :    join can copied by value and is generally stored as a stack variable. */
     388             : 
     389    15223983 : FD_FN_PURE static inline fd_funk_txn_map_t * fd_funk_txn_map( fd_funk_t * funk ) { return funk->txn_map; }
     390             : 
     391             : /* fd_funk_txn_pool returns the funk's transaction pool join. This
     392             :    join can copied by value and is generally stored as a stack variable. */
     393             : 
     394       78009 : FD_FN_PURE static inline fd_funk_txn_pool_t * fd_funk_txn_pool( fd_funk_t * funk ) { return funk->txn_pool; }
     395             : 
     396             : /* fd_funk_last_publish_child_{head,tail} returns a pointer in the
     397             :    caller's address space to {oldest,young} transaction child of root, NULL if
     398             :    funk is childless.  All pointers are in the caller's address space.
     399             :    These are all a fast O(1) but not fortified against memory data
     400             :    corruption. */
     401             : 
     402             : FD_FN_PURE static inline fd_funk_txn_t *
     403             : fd_funk_last_publish_child_head( fd_funk_t *          funk,
     404        5538 :                                  fd_funk_txn_pool_t * pool ) {
     405        5538 :   ulong idx = fd_funk_txn_idx( funk->shmem->child_head_cidx );
     406        5538 :   if( fd_funk_txn_idx_is_null( idx ) ) return NULL; /* TODO: Consider branchless? */
     407        5538 :   return pool->ele + idx;
     408        5538 : }
     409             : 
     410             : FD_FN_PURE static inline fd_funk_txn_t *
     411             : fd_funk_last_publish_child_tail( fd_funk_t *          funk,
     412        5538 :                                  fd_funk_txn_pool_t * pool ) {
     413        5538 :   ulong idx = fd_funk_txn_idx( funk->shmem->child_tail_cidx );
     414        5538 :   if( fd_funk_txn_idx_is_null( idx ) ) return NULL; /* TODO: Consider branchless? */
     415        5538 :   return pool->ele + idx;
     416        5538 : }
     417             : 
     418             : /* fd_funk_root returns a pointer in the caller's address space to the
     419             :    transaction id of the root transaction.  Assumes funk is a current
     420             :    local join.  Lifetime of the returned pointer is the lifetime of the
     421             :    current local join.  The value at this pointer will always be the
     422             :    root transaction id. */
     423             : 
     424      231492 : FD_FN_CONST static inline fd_funk_txn_xid_t const * fd_funk_root( fd_funk_t const * funk ) { return funk->shmem->root; }
     425             : 
     426             : /* fd_funk_last_publish returns a pointer in the caller's address space
     427             :    to transaction id of the last published transaction.  Assumes funk is
     428             :    a current local join.  Lifetime of the returned pointer is the
     429             :    lifetime of the current local join.  The value at this pointer will
     430             :    be constant until the next transaction is published. */
     431             : 
     432    14548851 : FD_FN_CONST static inline fd_funk_txn_xid_t const * fd_funk_last_publish( fd_funk_t const * funk ) { return funk->shmem->last_publish; }
     433             : 
     434             : /* fd_funk_is_frozen returns 1 if the records of the last published
     435             :    transaction are frozen (i.e. the funk has children) and 0 otherwise
     436             :    (i.e. the funk is childless).  Assumes funk is a current local join. */
     437             : 
     438             : FD_FN_PURE static inline int
     439     3146040 : fd_funk_last_publish_is_frozen( fd_funk_t const * funk ) {
     440     3146040 :   return fd_funk_txn_idx( funk->shmem->child_head_cidx )!=FD_FUNK_TXN_IDX_NULL;
     441     3146040 : }
     442             : 
     443             : /* fd_funk_rec_max returns maximum number of records that can be held
     444             :    in the funk.  This includes both records of the last published
     445             :    transaction and records for transactions that are in-flight. */
     446             : 
     447           0 : FD_FN_PURE static inline ulong fd_funk_rec_max( fd_funk_t * funk ) { return funk->rec_pool->ele_max; }
     448             : 
     449             : /* fd_funk_rec_map returns the funk's record map join. This
     450             :    join can copied by value and is generally stored as a stack variable. */
     451             : 
     452          12 : FD_FN_PURE static inline fd_funk_rec_map_t * fd_funk_rec_map( fd_funk_t * funk ) { return funk->rec_map; }
     453             : 
     454             : /* fd_funk_rec_pool returns the funk's record pool join. This
     455             :    join can copied by value and is generally stored as a stack variable. */
     456             : 
     457           0 : FD_FN_PURE static inline fd_funk_rec_pool_t * fd_funk_rec_pool( fd_funk_t * funk ) { return funk->rec_pool; }
     458             : 
     459             : /* fd_funk_alloc returns a pointer in the caller's address space to
     460             :    the funk's allocator. */
     461             : 
     462     1257960 : FD_FN_PURE static inline fd_alloc_t * fd_funk_alloc( fd_funk_t * funk ) { return funk->alloc; }
     463             : 
     464             : /* fd_funk_rec_is_full returns 1 if no more records can be allocated
     465             :    and 0 otherwise. */
     466             : 
     467             : static inline int
     468     2934600 : fd_funk_rec_is_full( fd_funk_t * funk ) {
     469     2934600 :   return fd_funk_rec_pool_is_empty( funk->rec_pool );
     470     2934600 : }
     471             : 
     472             : /* fd_funk_txn_is_full returns true if the transaction map is
     473             :    full. No more in-preparation transactions are allowed. */
     474             : 
     475             : static inline int
     476     1018962 : fd_funk_txn_is_full( fd_funk_t * funk ) {
     477     1018962 :   return fd_funk_txn_pool_is_empty( funk->txn_pool );
     478     1018962 : }
     479             : 
     480             : /* Misc */
     481             : 
     482             : /* fd_funk_verify verifies the integrity of funk.  Returns
     483             :    FD_FUNK_SUCCESS if funk appears to be intact and FD_FUNK_ERR_INVAL
     484             :    otherwise (logs details).  Assumes funk is a current local join (NULL
     485             :    returns FD_FUNK_ERR_INVAL and logs details.) */
     486             : 
     487             : int
     488             : fd_funk_verify( fd_funk_t * funk );
     489             : 
     490             : FD_PROTOTYPES_END
     491             : 
     492             : #endif /* HEADER_fd_src_funk_fd_funk_h */

Generated by: LCOV version 1.14