|
BitLab 0.1.0
BitLab: A Browser for the Bitcoin P2P Network and Blockchain
|
#include "peer_queue.h"#include <stdio.h>#include <stdlib.h>#include <string.h>#include <pthread.h>#include "utils.h"Go to the source code of this file.
Functions | |
| void | add_peer_to_queue (const char *ip, int port) |
| Add a peer to the queue. | |
| bool | is_peer_queue_empty () |
| Check if the peer queue is empty. | |
| bool | get_peer_from_queue (char *buffer, size_t buffer_size) |
| Get a peer from the queue. | |
| void | clear_peer_queue () |
| Clear the peer queue. | |
| void | print_peer_queue () |
| Print the peer queue. | |
| Peer * | get_peer_queue (int *count) |
| Get the peer queue. | |
Variables | |
| static Peer | peer_queue [MAX_PEERS] |
| static int | peer_queue_start = 0 |
| static int | peer_queue_end = 0 |
| static pthread_mutex_t | peer_queue_mutex = PTHREAD_MUTEX_INITIALIZER |
| void add_peer_to_queue | ( | const char * | ip, |
| int | port | ||
| ) |
Add a peer to the queue.
| ip | The IP address of the peer. |
| port | The port of the peer. |
Definition at line 15 of file peer_queue.c.
References BITLAB_LOG, Peer::ip, LOG_INFO, log_message(), LOG_WARN, MAX_PEERS, peer_queue, peer_queue_end, peer_queue_mutex, peer_queue_start, and Peer::port.
Referenced by handle_peer_discovery(), and send_getaddr_and_wait().
| void clear_peer_queue | ( | ) |
Clear the peer queue.
Definition at line 95 of file peer_queue.c.
References peer_queue_end, peer_queue_mutex, and peer_queue_start.
| bool get_peer_from_queue | ( | char * | buffer, |
| size_t | buffer_size | ||
| ) |
Get a peer from the queue.
| buffer | The buffer to store the peer. |
| buffer_size | The size of the buffer. |
Definition at line 80 of file peer_queue.c.
References MAX_PEERS, peer_queue, peer_queue_end, peer_queue_mutex, and peer_queue_start.
| Peer * get_peer_queue | ( | int * | count | ) |
Get the peer queue.
Definition at line 118 of file peer_queue.c.
References MAX_PEERS, peer_queue, peer_queue_end, peer_queue_mutex, and peer_queue_start.
Referenced by send_addr().
| bool is_peer_queue_empty | ( | ) |
Check if the peer queue is empty.
Definition at line 72 of file peer_queue.c.
References peer_queue_end, peer_queue_mutex, and peer_queue_start.
| void print_peer_queue | ( | ) |
Print the peer queue.
Definition at line 103 of file peer_queue.c.
References guarded_print_line(), MAX_PEERS, peer_queue, peer_queue_end, peer_queue_mutex, and peer_queue_start.
Referenced by cli_peer_discovery().
Definition at line 10 of file peer_queue.c.
Referenced by add_peer_to_queue(), get_peer_from_queue(), get_peer_queue(), and print_peer_queue().
|
static |
Definition at line 12 of file peer_queue.c.
Referenced by add_peer_to_queue(), clear_peer_queue(), get_peer_from_queue(), get_peer_queue(), is_peer_queue_empty(), and print_peer_queue().
|
static |
Definition at line 13 of file peer_queue.c.
Referenced by add_peer_to_queue(), clear_peer_queue(), get_peer_from_queue(), get_peer_queue(), is_peer_queue_empty(), and print_peer_queue().
|
static |
Definition at line 11 of file peer_queue.c.
Referenced by add_peer_to_queue(), clear_peer_queue(), get_peer_from_queue(), get_peer_queue(), is_peer_queue_empty(), and print_peer_queue().