Line data Source code
1 : #ifndef HEADER_fd_src_discof_restore_utils_fd_http_resolver_h 2 : #define HEADER_fd_src_discof_restore_utils_fd_http_resolver_h 3 : 4 : #include "fd_sspeer_selector.h" 5 : 6 : /* Resolves snapshot slot information for http snapshot peers. These 7 : peers might not publish SnapshotHashes messages through gossip, 8 : so we manually resolve their snapshot slot information through an 9 : http request. */ 10 : struct fd_http_resolver_private; 11 : typedef struct fd_http_resolver_private fd_http_resolver_t; 12 : 13 0 : #define FD_HTTP_RESOLVER_MAGIC (0xF17EDA2CE551170) /* FIREDANCE HTTP RESOLVER V0 */ 14 : 15 : typedef void 16 : (* fd_http_resolver_on_resolve_fn_t)( void * _ctx, 17 : fd_sspeer_key_t const * key, 18 : fd_ip4_port_t addr, 19 : ulong full_slot, 20 : ulong incr_slot, 21 : uchar full_hash[ FD_HASH_FOOTPRINT ], 22 : uchar incr_hash[ FD_HASH_FOOTPRINT ] ); 23 : 24 : FD_PROTOTYPES_BEGIN 25 : 26 : FD_FN_CONST ulong 27 : fd_http_resolver_align( void ); 28 : 29 : FD_FN_CONST ulong 30 : fd_http_resolver_footprint( ulong peers_cnt ); 31 : 32 : void * 33 : fd_http_resolver_new( void * shmem, 34 : ulong peers_cnt, 35 : int incremental_snapshot_fetch, 36 : int load_ca_store, 37 : fd_http_resolver_on_resolve_fn_t on_resolve_cb, 38 : void * cb_arg, 39 : int epoll_fd ); 40 : 41 : /* Add a peer to the resolver. Peers are not de-duplicated and must 42 : be unique. The peer is inserted into the selector with unknown 43 : slots and default latency so that subsequent on_resolve updates 44 : can find it. It becomes selectable by best() once resolved. 45 : Returns 0 on success, and -1 otherwise. */ 46 : int 47 : fd_http_resolver_add( fd_http_resolver_t * resolver, 48 : fd_ip4_port_t addr, 49 : char const * hostname, 50 : int is_https, 51 : fd_sspeer_selector_t * selector ); 52 : 53 : fd_http_resolver_t * 54 : fd_http_resolver_join( void * shresolve ); 55 : 56 : /* Advance the resolver forward in time until "now". Called 57 : periodically to continuously resolve snapshot slot information from 58 : peers. Takes a handle to the selector object to invalidate peers 59 : from both the resolver and selector. */ 60 : void 61 : fd_http_resolver_advance( fd_http_resolver_t * resolver, 62 : long now, 63 : fd_sspeer_selector_t * selector ); 64 : 65 : /* fd_http_resolver_next_deadline returns the earliest wallclock at 66 : which advance has timer work: a resolve times out, a valid peer is 67 : due a refresh, or an invalid one a retry. LONG_MAX if none. */ 68 : 69 : long 70 : fd_http_resolver_next_deadline( fd_http_resolver_t const * resolver ); 71 : 72 : FD_PROTOTYPES_END 73 : 74 : #endif /* HEADER_fd_src_discof_restore_utils_fd_http_resolver_h */