LCOV - code coverage report
Current view: top level - flamenco/repair - fd_repair.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 1 0.0 %
Date: 2024-11-13 11:58:15 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_flamenco_repair_fd_repair_h
       2             : #define HEADER_fd_src_flamenco_repair_fd_repair_h
       3             : 
       4             : #include "../gossip/fd_gossip.h"
       5             : #include "../../ballet/shred/fd_shred.h"
       6             : #include "../runtime/context/fd_exec_epoch_ctx.h"
       7             : 
       8             : #define FD_REPAIR_DELIVER_FAIL_TIMEOUT -1
       9           0 : #define FD_REPAIR_DELIVER_FAIL_REQ_LIMIT_EXCEEDED -2
      10             : 
      11             : /* Maximum size of a network packet */
      12             : #define FD_REPAIR_MAX_PACKET_SIZE 1232
      13             : 
      14             : /* Scratch space is used by the repair library to allocate an
      15             :    active element table and to shuffle that table.
      16             :    TODO: update comment to reflect the reasoning behind
      17             :    these constants once they are fully understood and updated. */
      18             : #define FD_REPAIR_SCRATCH_MAX    (1UL << 30UL)
      19             : #define FD_REPAIR_SCRATCH_DEPTH  (1UL << 11UL)
      20             : 
      21             : /* Global state of repair protocol */
      22             : typedef struct fd_repair fd_repair_t;
      23             : ulong         fd_repair_align    ( void );
      24             : ulong         fd_repair_footprint( void );
      25             : void *        fd_repair_new      ( void * shmem, ulong seed );
      26             : fd_repair_t * fd_repair_join     ( void * shmap );
      27             : void *        fd_repair_leave    ( fd_repair_t * join );
      28             : void *        fd_repair_delete   ( void * shmap );
      29             : 
      30             : typedef fd_gossip_peer_addr_t fd_repair_peer_addr_t;
      31             : 
      32             : /* Callback when a new shred is received */
      33             : typedef void (*fd_repair_shred_deliver_fun)( fd_shred_t const * shred, ulong shred_len, fd_repair_peer_addr_t const * from, fd_pubkey_t const * id, void * arg );
      34             : 
      35             : /* Callbacks when a repair is requested. shred_idx==-1 means the last index. */
      36             : typedef long (*fd_repair_serv_get_shred_fun)( ulong slot, uint shred_idx, void * buf, ulong buf_max, void * arg );
      37             : typedef ulong (*fd_repair_serv_get_parent_fun)( ulong slot, void * arg );
      38             : 
      39             : /* Callback for sending a packet. addr is the address of the destination. */
      40             : typedef void (*fd_repair_send_packet_fun)( uchar const * msg, size_t msglen, fd_repair_peer_addr_t const * addr, void * arg );
      41             : 
      42             : /* Callback signing */
      43             : typedef void (*fd_repair_sign_fun)( void * ctx, uchar * sig, uchar const * buffer, ulong len, int sign_type );
      44             : 
      45             : /* Callback for when a request fails. Echoes back the request parameters. */
      46             : typedef void (*fd_repair_shred_deliver_fail_fun)( fd_pubkey_t const * id, ulong slot, uint shred_index, void * arg, int reason );
      47             : 
      48             : struct fd_repair_config {
      49             :     fd_pubkey_t * public_key;
      50             :     uchar * private_key;
      51             :     fd_repair_peer_addr_t service_addr;
      52             :     fd_repair_peer_addr_t intake_addr;
      53             :     fd_repair_shred_deliver_fun deliver_fun;
      54             :     fd_repair_serv_get_shred_fun serv_get_shred_fun;
      55             :     fd_repair_serv_get_parent_fun serv_get_parent_fun;
      56             :     fd_repair_send_packet_fun clnt_send_fun; /* sending client requests */
      57             :     fd_repair_send_packet_fun serv_send_fun; /* sending service responses */
      58             :     fd_repair_shred_deliver_fail_fun deliver_fail_fun;
      59             :     void * fun_arg;
      60             :     fd_repair_sign_fun sign_fun;
      61             :     void * sign_arg;
      62             : };
      63             : typedef struct fd_repair_config fd_repair_config_t;
      64             : 
      65             : /* Initialize the repair data structure */
      66             : int fd_repair_set_config( fd_repair_t * glob, const fd_repair_config_t * config );
      67             : 
      68             : /* Update the binding addr */
      69             : int fd_repair_update_addr( fd_repair_t * glob, const fd_repair_peer_addr_t * intake_addr, const fd_repair_peer_addr_t * service_addr );
      70             : 
      71             : /* Add a peer to talk to */
      72             : int fd_repair_add_active_peer( fd_repair_t * glob, fd_repair_peer_addr_t const * addr, fd_pubkey_t const * id );
      73             : 
      74             : /* Set the current protocol time in nanosecs. Call this as often as feasible. */
      75             : void fd_repair_settime( fd_repair_t * glob, long ts );
      76             : 
      77             : /* Get the current protocol time in nanosecs */
      78             : long fd_repair_gettime( fd_repair_t * glob );
      79             : 
      80             : /* Start timed events and other protocol behavior. settime MUST be called before this. */
      81             : int fd_repair_start( fd_repair_t * glob );
      82             : 
      83             : /* Dispatch timed events and other protocol behavior. This should be
      84             :  * called inside the main spin loop. calling settime first is recommended. */
      85             : int fd_repair_continue( fd_repair_t * glob );
      86             : 
      87             : /* Pass a raw client response packet into the protocol. addr is the address of the sender */
      88             : int fd_repair_recv_clnt_packet( fd_repair_t * glob, uchar const * msg, ulong msglen, fd_repair_peer_addr_t const * addr );
      89             : 
      90             : /* Pass a raw service request packet into the protocol. addr is the address of the sender */
      91             : int fd_repair_recv_serv_packet( fd_repair_t * glob, uchar const * msg, ulong msglen, fd_repair_peer_addr_t const * addr );
      92             : 
      93             : /* Determine if the request queue is full */
      94             : int fd_repair_is_full( fd_repair_t * glob );
      95             : 
      96             : /* Register a request for a shred */
      97             : int fd_repair_need_window_index( fd_repair_t * glob, ulong slot, uint shred_index );
      98             : 
      99             : int fd_repair_need_highest_window_index( fd_repair_t * glob, ulong slot, uint shred_index );
     100             : 
     101             : int fd_repair_need_orphan( fd_repair_t * glob, ulong slot );
     102             : 
     103             : void fd_repair_add_sticky( fd_repair_t * glob, fd_pubkey_t const * id );
     104             : 
     105             : void fd_repair_set_permanent( fd_repair_t * glob, fd_pubkey_t const * id );
     106             : 
     107             : void fd_repair_set_stake_weights( fd_repair_t * repair,
     108             :                                   fd_stake_weight_t const * stake_weights,
     109             :                                   ulong stake_weights_cnt );
     110             : 
     111             : #endif /* HEADER_fd_src_flamenco_repair_fd_repair_h */

Generated by: LCOV version 1.14