LCOV - code coverage report
Current view: top level - flamenco/stakes - fd_stake_types.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 2 5 40.0 %
Date: 2026-03-31 06:22:16 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_flamenco_stakes_fd_stake_types_h
       2             : #define HEADER_fd_src_flamenco_stakes_fd_stake_types_h
       3             : 
       4             : #include "../types/fd_types_custom.h"
       5             : 
       6          27 : #define FD_STAKE_STATE_SZ (200UL)
       7             : 
       8           0 : #define FD_STAKE_STATE_UNINITIALIZED 0U
       9           0 : #define FD_STAKE_STATE_INITIALIZED   1U
      10          12 : #define FD_STAKE_STATE_STAKE         2U
      11           0 : #define FD_STAKE_STATE_REWARDS_POOL  3U
      12             : 
      13             : struct __attribute__((packed)) fd_stake_meta {
      14             :   ulong       rent_exempt_reserve;
      15             :   fd_pubkey_t staker;
      16             :   fd_pubkey_t withdrawer;
      17             :   long        unix_timestamp;
      18             :   ulong       epoch;
      19             :   fd_pubkey_t custodian;
      20             : };
      21             : typedef struct fd_stake_meta fd_stake_meta_t;
      22             : 
      23             : struct __attribute__((packed)) fd_delegation {
      24             :   fd_pubkey_t voter_pubkey;
      25             :   ulong       stake;
      26             :   ulong       activation_epoch;
      27             :   ulong       deactivation_epoch;
      28             :   union {
      29             : #   if FD_HAS_DOUBLE
      30             :     double    warmup_cooldown_rate;
      31             : #   endif
      32             :     ulong     warmup_cooldown_rate_bits;
      33             :   };
      34             : };
      35             : typedef struct fd_delegation fd_delegation_t;
      36             : 
      37             : struct __attribute__((packed)) fd_stake {
      38             :   fd_delegation_t delegation;
      39             :   ulong           credits_observed;
      40             : };
      41             : typedef struct fd_stake fd_stake_t;
      42             : 
      43             : struct __attribute__((packed)) fd_stake_state {
      44             :   uint stake_type;
      45             :   union {
      46             :     struct __attribute__((packed)) {
      47             :       fd_stake_meta_t meta;
      48             :     } initialized;
      49             : 
      50             :     struct __attribute__((packed)) {
      51             :       fd_stake_meta_t meta;
      52             :       fd_stake_t      stake;
      53             :       uchar           stake_flags;
      54             :     } stake;
      55             :   };
      56             : };
      57             : typedef struct fd_stake_state fd_stake_state_t;
      58             : 
      59             : FD_PROTOTYPES_BEGIN
      60             : 
      61             : /* fd_stake_state_view attempts to reinterpret the pointer to serialized
      62             :    stake state data as a pointer to a fd_stake_state_t struct.
      63             : 
      64             :    Runs various canonical bincode deserialization checks.  If they pass,
      65             :    returns a cast of data.  On deserialization failure, returns NULL.
      66             :    Note that trailing data is silently ignored. */
      67             : 
      68             : fd_stake_state_t const *
      69             : fd_stake_state_view( uchar const * data,
      70             :                      ulong         data_sz );
      71             : 
      72             : FD_PROTOTYPES_END
      73             : 
      74             : #endif /* HEADER_fd_src_flamenco_stakes_fd_stake_types_h */

Generated by: LCOV version 1.14