LCOV - code coverage report
Current view: top level - disco/keyguard - fd_keyguard_client.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 30 0.0 %
Date: 2025-03-20 12:08:36 Functions: 0 2 0.0 %

          Line data    Source code
       1             : #include "fd_keyguard_client.h"
       2             : 
       3             : void *
       4             : fd_keyguard_client_new( void *         shmem,
       5             :                         fd_frag_meta_t * request_mcache,
       6             :                         uchar *          request_data,
       7             :                         fd_frag_meta_t * response_mcache,
       8           0 :                         uchar *          response_data ) {
       9           0 :   fd_keyguard_client_t * client = (fd_keyguard_client_t*)shmem;
      10           0 :   client->request       = request_mcache;
      11           0 :   client->request_depth = fd_mcache_depth( request_mcache );
      12           0 :   client->request_seq   = 0UL;
      13           0 :   client->request_data  = request_data;
      14             : 
      15           0 :   client->response       = response_mcache;
      16           0 :   client->response_depth = fd_mcache_depth( response_mcache );
      17           0 :   client->response_seq   = 0UL;
      18           0 :   client->response_data  = response_data;
      19           0 :   return shmem;
      20           0 : }
      21             : 
      22             : void
      23             : fd_keyguard_client_sign( fd_keyguard_client_t * client,
      24             :                          uchar *                signature,
      25             :                          uchar const *          sign_data,
      26             :                          ulong                  sign_data_len,
      27           0 :                          int                    sign_type ) {
      28             : 
      29           0 :   fd_memcpy( client->request_data, sign_data, sign_data_len );
      30             : 
      31           0 :   ulong sig = (ulong)(uint)sign_type;
      32           0 :   fd_mcache_publish( client->request, client->request_depth, client->request_seq, sig, 0UL, sign_data_len, 0UL, 0UL, 0UL );
      33           0 :   client->request_seq = fd_seq_inc( client->request_seq, 1UL );
      34             : 
      35           0 :   fd_frag_meta_t meta;
      36           0 :   fd_frag_meta_t const * mline;
      37           0 :   ulong seq_found;
      38           0 :   long seq_diff;
      39           0 :   ulong poll_max = ULONG_MAX;
      40           0 :   FD_MCACHE_WAIT( &meta, mline, seq_found, seq_diff, poll_max, client->response, client->response_depth, client->response_seq );
      41           0 :   if( FD_UNLIKELY( !poll_max ) ) FD_LOG_ERR(( "sign request timed out while polling" ));
      42           0 :   if( FD_UNLIKELY( seq_diff ) ) FD_LOG_ERR(( "sign request was overrun while polling" ));
      43             : 
      44           0 :   fd_memcpy( signature, client->response_data, 64UL );
      45             : 
      46           0 :   seq_found = fd_frag_meta_seq_query( mline );
      47           0 :   if( FD_UNLIKELY( fd_seq_ne( seq_found, client->response_seq ) ) ) FD_LOG_ERR(( "sign request was overrun while reading" ));
      48           0 :   client->response_seq = fd_seq_inc( client->response_seq, 1UL );
      49           0 : }

Generated by: LCOV version 1.14