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 : ulong full_slot, 19 : ulong incr_slot, 20 : uchar full_hash[ FD_HASH_FOOTPRINT ], 21 : uchar incr_hash[ FD_HASH_FOOTPRINT ] ); 22 : 23 : FD_PROTOTYPES_BEGIN 24 : 25 : FD_FN_CONST ulong 26 : fd_http_resolver_align( void ); 27 : 28 : FD_FN_CONST ulong 29 : fd_http_resolver_footprint( ulong peers_cnt ); 30 : 31 : void * 32 : fd_http_resolver_new( void * shmem, 33 : ulong peers_cnt, 34 : int incremental_snapshot_fetch, 35 : fd_http_resolver_on_resolve_fn_t on_resolve_cb, 36 : void * cb_arg ); 37 : 38 : /* Add a peer to the resolver. Peers are not de-duplicated and must 39 : be unique. The peer will be added to the selector with default 40 : data regarding latency, full/incr slot as well as full/incr hash. 41 : Adding it to the selector guarantees that any subsequent update on 42 : the latter can find it. Returns 0 on success, and -1 otherwise. */ 43 : int 44 : fd_http_resolver_add( fd_http_resolver_t * resolver, 45 : fd_ip4_port_t addr, 46 : char const * hostname, 47 : int is_https, 48 : fd_sspeer_selector_t * selector ); 49 : 50 : fd_http_resolver_t * 51 : fd_http_resolver_join( void * shresolve ); 52 : 53 : /* Advance the resolver forward in time until "now". Called 54 : periodically to continuously resolve snapshot slot information from 55 : peers. Takes a handle to the selector object to invalidate peers 56 : from both the resolver and selector. */ 57 : void 58 : fd_http_resolver_advance( fd_http_resolver_t * resolver, 59 : long now, 60 : fd_sspeer_selector_t * selector ); 61 : 62 : FD_PROTOTYPES_END 63 : 64 : #endif /* HEADER_fd_src_discof_restore_utils_fd_http_resolver_h */