LCOV - code coverage report
Current view: top level - flamenco/stakes - fd_stake_types.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 3 5 60.0 %
Date: 2026-09-17 04:28:31 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 "../fd_flamenco_base.h"
       5             : 
       6       16116 : #define FD_STAKE_STATE_SZ (200UL)
       7             : 
       8           0 : #define FD_STAKE_STATE_UNINITIALIZED 0U
       9           3 : #define FD_STAKE_STATE_INITIALIZED   1U
      10         399 : #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             :     double    warmup_cooldown_rate;
      30             :     ulong     warmup_cooldown_rate_bits;
      31             :   };
      32             : };
      33             : typedef struct fd_delegation fd_delegation_t;
      34             : 
      35             : struct __attribute__((packed)) fd_stake {
      36             :   fd_delegation_t delegation;
      37             :   ulong           credits_observed;
      38             : };
      39             : typedef struct fd_stake fd_stake_t;
      40             : 
      41             : struct __attribute__((packed)) fd_stake_state {
      42             :   uint stake_type;
      43             :   union {
      44             :     struct __attribute__((packed)) {
      45             :       fd_stake_meta_t meta;
      46             :     } initialized;
      47             : 
      48             :     struct __attribute__((packed)) {
      49             :       fd_stake_meta_t meta;
      50             :       fd_stake_t      stake;
      51             :       uchar           stake_flags;
      52             :     } stake;
      53             :   };
      54             : };
      55             : typedef struct fd_stake_state fd_stake_state_t;
      56             : 
      57             : FD_PROTOTYPES_BEGIN
      58             : 
      59             : /* fd_stake_state_view attempts to reinterpret the pointer to serialized
      60             :    stake state data as a pointer to a fd_stake_state_t struct.
      61             : 
      62             :    Runs various canonical bincode deserialization checks.  If they pass,
      63             :    returns a cast of data.  On deserialization failure, returns NULL.
      64             :    Note that trailing data is silently ignored. */
      65             : 
      66             : fd_stake_state_t const *
      67             : fd_stake_state_view( uchar const * data,
      68             :                      ulong         data_sz );
      69             : 
      70             : FD_PROTOTYPES_END
      71             : 
      72             : #endif /* HEADER_fd_src_flamenco_stakes_fd_stake_types_h */

Generated by: LCOV version 1.14