Line data Source code
1 : #ifndef HEADER_fd_src_ballet_bmtree_fd_wbmtree_h 2 : #define HEADER_fd_src_ballet_bmtree_fd_wbmtree_h 3 : 4 : #include "../sha256/fd_sha256.h" 5 : 6 : /* This files declares another implementation of the binary Merkle 7 : tree based on the SHA-256 hash function. 8 : 9 : This difference between this one and the fd_bmtree version is this 10 : one optimizes for performance at the expense of memory and uses the 11 : streaming sha256 APIs. 12 : */ 13 : 14 : struct fd_wbmtree32_leaf { 15 : unsigned char *data; 16 : unsigned long data_len; 17 : }; 18 : typedef struct fd_wbmtree32_leaf fd_wbmtree32_leaf_t; 19 : 20 : struct fd_wbmtree32_node { 21 : uchar hash[ 33UL ]; 22 : }; 23 : typedef struct fd_wbmtree32_node fd_wbmtree32_node_t; 24 : 25 0 : #define FD_WBMTREE32_ALIGN (128UL) 26 : 27 : /* the alignment of fd_wbmtree32 needs to match the alignment of the 28 : fd_sha256_batch object */ 29 : struct __attribute__((aligned(FD_WBMTREE32_ALIGN))) fd_wbmtree32 { 30 : fd_sha256_batch_t sha256_batch; 31 : ulong leaf_cnt_max; 32 : ulong leaf_cnt; 33 : fd_wbmtree32_node_t data[]; 34 : }; 35 : typedef struct fd_wbmtree32 fd_wbmtree32_t; 36 : 37 : FD_PROTOTYPES_BEGIN 38 : 39 : ulong fd_wbmtree32_align ( void ); 40 : ulong fd_wbmtree32_footprint ( ulong leaf_cnt ); 41 : fd_wbmtree32_t* fd_wbmtree32_init ( void * mem, ulong leaf_cnt ); 42 : void fd_wbmtree32_append ( fd_wbmtree32_t * bmt, fd_wbmtree32_leaf_t const * leaf, ulong leaf_cnt, uchar *mbuf ); 43 : uchar * fd_wbmtree32_fini ( fd_wbmtree32_t * bmt); 44 : 45 : FD_PROTOTYPES_END 46 : 47 : #endif /*HEADER_fd_src_ballet_bmtree_fd_wbmtree_h*/