LCOV - code coverage report
Current view: top level - flamenco/accdb - fd_accdb_admin.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 6 15 40.0 %
Date: 2026-03-19 18:19:27 Functions: 4 170 2.4 %

          Line data    Source code
       1             : #ifndef HEADER_fd_src_flamenco_accdb_fd_accdb_admin_h
       2             : #define HEADER_fd_src_flamenco_accdb_fd_accdb_admin_h
       3             : 
       4             : #include "fd_accdb_base.h"
       5             : #include "fd_accdb_user.h"
       6             : #include "../../funk/fd_funk_base.h"
       7             : 
       8             : /* fd_accdb_admin_vt_t specifies the interface (vtable) for the account
       9             :    DB admin. */
      10             : 
      11             : struct fd_accdb_admin_vt {
      12             : 
      13             :   void
      14             :   (* fini)( fd_accdb_admin_t * accdb );
      15             : 
      16             :   fd_funk_txn_xid_t
      17             :   (* root_get)( fd_accdb_admin_t const * admin );
      18             : 
      19             :   void
      20             :   (* attach_child)( fd_accdb_admin_t *        admin,
      21             :                     fd_funk_txn_xid_t const * xid_parent,
      22             :                     fd_funk_txn_xid_t const * xid_new );
      23             : 
      24             :   void
      25             :   (* advance_root)( fd_accdb_admin_t *        admin,
      26             :                     fd_funk_txn_xid_t const * xid );
      27             : 
      28             :   void
      29             :   (* cancel)( fd_accdb_admin_t *        admin,
      30             :               fd_funk_txn_xid_t const * xid );
      31             : 
      32             : };
      33             : 
      34             : typedef struct fd_accdb_admin_vt fd_accdb_admin_vt_t;
      35             : 
      36             : struct fd_accdb_admin_base {
      37             :   fd_accdb_admin_vt_t const * vt;
      38             :   uint                        accdb_type;
      39             : 
      40             :   ulong rw_active;
      41             :   ulong ro_active;
      42             :   ulong created_cnt;
      43             :   ulong root_cnt;     /* moved to database root */
      44             :   ulong root_tot_sz;  /* number of bytes moved while rooting */
      45             :   ulong reclaim_cnt;  /* 0 lamport account removed while rooting */
      46             :   ulong gc_root_cnt;  /* stale rooted revisions removed while rooting */
      47             :   ulong revert_cnt;   /* abandoned by consensus */
      48             : 
      49             :   /* cumulative tickcount spent on various admin operations */
      50             :   long dt_vinyl;  /* waiting on vinyl completinos */
      51             :   long dt_copy;   /* copying account data */
      52             :   long dt_gc;     /* garbage collecting data */
      53             : };
      54             : 
      55             : typedef struct fd_accdb_admin_base fd_accdb_admin_base_t;
      56             : 
      57             : struct fd_accdb_admin {
      58             :   fd_accdb_admin_base_t base;
      59             : 
      60             :   uchar impl[ FD_ACCDB_IMPL_FOOTPRINT ] __attribute__((aligned(64)));
      61             : };
      62             : 
      63             : FD_PROTOTYPES_BEGIN
      64             : 
      65             : static inline void
      66          12 : fd_accdb_admin_fini( fd_accdb_admin_t * accdb ) {
      67          12 :   accdb->base.vt->fini( accdb );
      68          12 : }
      69             : 
      70             : /* Transaction-level operations ***************************************/
      71             : 
      72             : static inline fd_funk_txn_xid_t
      73           0 : fd_accdb_root_get( fd_accdb_admin_t const * admin ) {
      74           0 :   return admin->base.vt->root_get( admin );
      75           0 : }
      76             : 
      77             : /* FIXME rename these to?
      78             :          - fd_accdb_fork_create
      79             :          - fd_accdb_fork_freeze
      80             :          - fd_accdb_fork_commit_root
      81             :          - fd_accdb_fork_cancel */
      82             : 
      83             : /* fd_accdb_attach_child creates a new account database fork node off a
      84             :    frozen parent or the root.
      85             : 
      86             :    It is assumed that less than txn_max non-root transaction exist when
      87             :    this is called. */
      88             : 
      89             : static inline void
      90             : fd_accdb_attach_child( fd_accdb_admin_t *        admin,
      91             :                        fd_funk_txn_xid_t const * xid_parent,
      92       54868 :                        fd_funk_txn_xid_t const * xid_new ) {
      93       54868 :   admin->base.vt->attach_child( admin, xid_parent, xid_new );
      94       54868 : }
      95             : 
      96             : /* fd_accdb_advance_root merges the given fork node into the database
      97             :    root. */
      98             : 
      99             : static inline void
     100             : fd_accdb_advance_root( fd_accdb_admin_t *        admin,
     101           0 :                        fd_funk_txn_xid_t const * xid ) {
     102           0 :   admin->base.vt->advance_root( admin, xid );
     103           0 : }
     104             : 
     105             : /* fd_accdb_cancel removes a fork node by XID and its children
     106             :    (recursively). */
     107             : 
     108             : static inline void
     109             : fd_accdb_cancel( fd_accdb_admin_t *        admin,
     110           0 :                  fd_funk_txn_xid_t const * xid ) {
     111           0 :   admin->base.vt->cancel( admin, xid );
     112           0 : }
     113             : 
     114             : FD_PROTOTYPES_END
     115             : 
     116             : #endif /* HEADER_fd_src_flamenco_accdb_fd_accdb_admin_h */

Generated by: LCOV version 1.14