LCOV - code coverage report
Current view: top level - disco/keyguard - fd_keyguard_client.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 28 0.0 %
Date: 2024-11-13 11:58:15 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_seq  = 0UL;
      12           0 :   client->request_data = request_data;
      13             : 
      14           0 :   client->response      = response_mcache;
      15           0 :   client->response_seq  = 0UL;
      16           0 :   client->response_data = response_data;
      17           0 :   return shmem;
      18           0 : }
      19             : 
      20             : void
      21             : fd_keyguard_client_sign( fd_keyguard_client_t * client,
      22             :                          uchar *                signature,
      23             :                          uchar const *          sign_data,
      24             :                          ulong                  sign_data_len,
      25           0 :                          int                    sign_type ) {
      26             : 
      27           0 :   fd_memcpy( client->request_data, sign_data, sign_data_len );
      28             : 
      29           0 :   ulong sig = (ulong)(uint)sign_type;
      30           0 :   fd_mcache_publish( client->request, 128UL, client->request_seq, sig, 0UL, sign_data_len, 0UL, 0UL, 0UL );
      31           0 :   client->request_seq = fd_seq_inc( client->request_seq, 1UL );
      32             : 
      33           0 :   fd_frag_meta_t meta;
      34           0 :   fd_frag_meta_t const * mline;
      35           0 :   ulong seq_found;
      36           0 :   long seq_diff;
      37           0 :   ulong poll_max = ULONG_MAX;
      38           0 :   FD_MCACHE_WAIT( &meta, mline, seq_found, seq_diff, poll_max, client->response, 128UL, client->response_seq );
      39           0 :   if( FD_UNLIKELY( !poll_max ) ) FD_LOG_ERR(( "sign request timed out while polling" ));
      40           0 :   if( FD_UNLIKELY( seq_diff ) ) FD_LOG_ERR(( "sign request was overrun while polling" ));
      41             : 
      42           0 :   fd_memcpy( signature, client->response_data, 64UL );
      43             : 
      44           0 :   seq_found = fd_frag_meta_seq_query( mline );
      45           0 :   if( FD_UNLIKELY( fd_seq_ne( seq_found, client->response_seq ) ) ) FD_LOG_ERR(( "sign request was overrun while reading" ));
      46           0 :   client->response_seq = fd_seq_inc( client->response_seq, 1UL );
      47           0 : }

Generated by: LCOV version 1.14