BitLab 0.1.0
BitLab: A Browser for the Bitcoin P2P Network and Blockchain
Loading...
Searching...
No Matches
state.h
Go to the documentation of this file.
1#ifndef __STATE_H
2#define __STATE_H
3
4#define BITLAB_VERSION "0.1.0"
5
6#define PEER_DISCOVERY_DEFAULT_DAEMON false
7#define PEER_DISCOVERY_DEFAULT_HARDCODED_SEEDS false
8#define PEER_DISCOVERY_DEFAULT_DNS_LOOKUP true
9
10#include <signal.h>
11#include <stdbool.h>
12#include <unistd.h>
13#include <time.h>
14#include <fcntl.h>
15#include <pthread.h>
16
26typedef struct
27{
28 pid_t pid;
29 time_t start_time;
31 volatile sig_atomic_t exit_flag;
32 pthread_mutex_t exit_flag_mutex;
34
58
62extern program_state state;
63
68
73
78
84void set_exit_flag(volatile sig_atomic_t flag);
85
91sig_atomic_t get_exit_flag();
92
97
102
109
114
120void finish_peer_discovery_progress(bool succeeded);
121
128bool set_peer_discovery(bool value);
129
136
142bool get_peer_discovery();
143
150
157
164bool set_peer_discovery_daemon(bool value);
165
173
180bool set_peer_discovery_dns_lookup(bool value);
181
188
195
202
209bool set_peer_discovery_dns_domain(const char* domain);
210
217
222
228int get_pid();
229
235time_t get_start_time();
236
242int get_elapsed_time();
243
244#endif // __STATE_H
bool set_peer_discovery_daemon(bool value)
Set the peer discovery daemon state.
Definition state.c:174
bool get_peer_discovery()
Get the peer discovery operation.
Definition state.c:150
bool set_peer_discovery_hardcoded_seeds(bool value)
Set the peer discovery hardcoded seeds state.
Definition state.c:182
bool get_peer_discovery_in_progress()
Get the peer discovery in progress state.
Definition state.c:158
bool set_peer_discovery_dns_lookup(bool value)
Set the peer discovery DNS lookup state.
Definition state.c:190
bool set_peer_discovery_dns_domain(const char *domain)
Set the peer discovery DNS domain.
Definition state.c:222
void destroy_program_state()
Destroy the program state.
Definition state.c:95
int get_elapsed_time()
Get the elapsed time since the program started.
Definition state.c:262
bool get_peer_discovery_hardcoded_seeds()
Get the peer discovery hardcoded seeds state.
Definition state.c:206
void print_program_state()
Print the program state.
Definition state.c:63
void destroy_program_operation()
Clear all program operations.
Definition state.c:247
program_state state
The program state used to store the state of the program.
Definition state.c:19
void set_exit_flag(volatile sig_atomic_t flag)
Set the exit flag.
Definition state.c:73
bool get_peer_discovery_succeeded()
Get the peer discovery succeeded state.
Definition state.c:166
void start_peer_discovery_progress()
Start the peer discovery progress.
Definition state.c:107
int get_pid()
Get the program PID.
Definition state.c:252
void mark_started_with_parameters()
Mark the program as started with parameters.
Definition state.c:88
int init_program_operation()
Initialize the program operation.
Definition state.c:100
program_operation operation
The program operation used to store all current operations of the program.
Definition state.c:40
bool set_peer_discovery(bool value)
Set the peer discovery operation.
Definition state.c:125
bool get_peer_discovery_daemon()
Get the peer discovery daemon state.
Definition state.c:198
const char * get_peer_discovery_dns_domain()
Get the peer discovery DNS domain.
Definition state.c:239
sig_atomic_t get_exit_flag()
Get the exit flag.
Definition state.c:80
void init_program_state()
Initialize the program state.
Definition state.c:52
void finish_peer_discovery_progress(bool succeeded)
Finish the peer discovery progress.
Definition state.c:117
bool force_stop_peer_discovery()
Force stop the peer discovery operation.
Definition state.c:140
time_t get_start_time()
Get the program start time.
Definition state.c:257
bool get_peer_discovery_dns_lookup()
Get the peer discovery DNS lookup state.
Definition state.c:214
The program operation structure used to store the operation of the program.
Definition state.h:48
bool peer_discovery_succeeded
Definition state.h:51
bool peer_discovery_in_progress
Definition state.h:50
char * peer_discovery_dns_domain
Definition state.h:55
bool peer_discovery_daemon
Definition state.h:52
bool peer_discovery_dns_lookup
Definition state.h:54
bool peer_discovery_hardcoded_seeds
Definition state.h:53
bool peer_discovery
Definition state.h:49
pthread_mutex_t operation_mutex
Definition state.h:56
The program state structure used to store the state of the program.
Definition state.h:27
volatile sig_atomic_t exit_flag
Definition state.h:31
pthread_mutex_t exit_flag_mutex
Definition state.h:32
pid_t pid
Definition state.h:28
bool started_with_parameters
Definition state.h:30
time_t start_time
Definition state.h:29