Data Structures | Enumerations | Functions
consdiffmgr.h File Reference

Header for consdiffmgr.c. More...

Go to the source code of this file.

Data Structures

struct  consdiff_cfg_t




int consdiffmgr_add_consensus (const char *consensus, size_t consensus_len, const networkstatus_t *as_parsed)
consdiff_status_t consdiffmgr_find_consensus (struct consensus_cache_entry_t **entry_out, consensus_flavor_t flavor, enum compress_method_t method)
consdiff_status_t consdiffmgr_find_diff_from (struct consensus_cache_entry_t **entry_out, consensus_flavor_t flavor, int digest_type, const uint8_t *digest, size_t digestlen, enum compress_method_t method)
int consensus_cache_entry_get_voter_id_digests (const struct consensus_cache_entry_t *ent, smartlist_t *out)
int consensus_cache_entry_get_fresh_until (const struct consensus_cache_entry_t *ent, time_t *out)
int consensus_cache_entry_get_valid_until (const struct consensus_cache_entry_t *ent, time_t *out)
int consensus_cache_entry_get_valid_after (const struct consensus_cache_entry_t *ent, time_t *out)
void consdiffmgr_rescan (void)
int consdiffmgr_cleanup (void)
void consdiffmgr_enable_background_compression (void)
void consdiffmgr_configure (const consdiff_cfg_t *cfg)
int consdiffmgr_register_with_sandbox (struct sandbox_cfg_elem_t **cfg)
void consdiffmgr_free_all (void)
int consdiffmgr_validate (void)

Detailed Description

Header for consdiffmgr.c.

Definition in file consdiffmgr.h.

Enumeration Type Documentation

◆ consdiff_status_t

Possible outcomes from trying to look up a given consensus diff.

Definition at line 17 of file consdiffmgr.h.

Function Documentation

◆ consdiffmgr_add_consensus()

int consdiffmgr_add_consensus ( const char *  consensus,
size_t  consensus_len,
const networkstatus_t as_parsed 

Given a buffer containing a networkstatus consensus, and the results of having parsed that consensus, add that consensus to the cache if it is not already present and not too old. Create new consensus diffs from or to that consensus as appropriate.

Return 0 on success and -1 on failure.

Definition at line 549 of file consdiffmgr.c.

◆ consdiffmgr_cleanup()

int consdiffmgr_cleanup ( void  )

Perform periodic cleanup tasks on the consensus diff cache. Return the number of objects marked for deletion.

Definition at line 722 of file consdiffmgr.c.

Referenced by consdiffmgr_ensure_space_for_files(), and consdiffmgr_rescan().

◆ consdiffmgr_configure()

void consdiffmgr_configure ( const consdiff_cfg_t cfg)

Initialize the consensus diff manager and its cache, and configure its parameters based on the latest torrc and networkstatus parameters.

Definition at line 844 of file consdiffmgr.c.

◆ consdiffmgr_enable_background_compression()

void consdiffmgr_enable_background_compression ( void  )

Tell the consdiffmgr backend to compress consensuses in worker threads.

Definition at line 1918 of file consdiffmgr.c.

◆ consdiffmgr_find_consensus()

consdiff_status_t consdiffmgr_find_consensus ( struct consensus_cache_entry_t **  entry_out,
consensus_flavor_t  flavor,
compress_method_t  method 

If we know a consensus with the flavor flavor compressed with method, set *entry_out to that value. Return values are as for consdiffmgr_find_diff_from().

Definition at line 629 of file consdiffmgr.c.

◆ consdiffmgr_find_diff_from()

consdiff_status_t consdiffmgr_find_diff_from ( consensus_cache_entry_t **  entry_out,
consensus_flavor_t  flavor,
int  digest_type,
const uint8_t *  digest,
size_t  digestlen,
compress_method_t  method 

Look up consensus_cache_entry_t for the consensus of type flavor, from the source consensus with the specified digest (which must be SHA3).

If the diff is present, store it into *entry_out and return CONSDIFF_AVAILABLE. Otherwise return CONSDIFF_NOT_FOUND or CONSDIFF_IN_PROGRESS.

Definition at line 660 of file consdiffmgr.c.

◆ consdiffmgr_free_all()

void consdiffmgr_free_all ( void  )

Called before shutdown: drop all storage held by the consdiffmgr.c module.

Definition at line 1267 of file consdiffmgr.c.

◆ consdiffmgr_register_with_sandbox()

int consdiffmgr_register_with_sandbox ( struct sandbox_cfg_elem_t **  cfg)

Tell the sandbox (if any) configured by cfg to allow the operations that the consensus diff manager will need.

Definition at line 857 of file consdiffmgr.c.

◆ consdiffmgr_rescan()

void consdiffmgr_rescan ( void  )

Build new diffs as needed.

Definition at line 1121 of file consdiffmgr.c.

Referenced by consdiffmgr_rescan_cb().

◆ consdiffmgr_validate()

int consdiffmgr_validate ( void  )

Scan the consensus diff manager's cache for any grossly malformed entries, and mark them as deletable. Return 0 if no problems were found; 1 if problems were found and fixed.

Definition at line 868 of file consdiffmgr.c.