OlinCoin
Test
src
includes
globals
mempool.h
1
#pragma once
2
3
#include <stdio.h>
4
#include "constants.h"
5
#include "uthash.h"
6
#include "base_tx.h"
7
8
typedef
struct
MemPool
{
9
unsigned
char
id
[TX_HASH_LEN];
10
Transaction
*tx;
11
UT_hash_handle hh;
12
}
MemPool
;
13
14
MemPool
*mempool;
15
16
/* Initializes the global mempool variable */
17
void
mempool_init();
18
19
/* Creates a new entry in the hashmap with the passed transaction
20
*
21
* Returns passed transaction pointer if entry created, NULL otherwise
22
*
23
* transaction: Transaction pointer that will be stored in entry
24
*/
25
Transaction
*mempool_add(
Transaction
*tx);
26
27
/* Removes the entry corresponding to tx_hash
28
*
29
* Returns the transaction pointer stored in removed entry if succesfully
30
* removed, NULL otherwise
31
*
32
* tx_hash: Buffer of length TX_HASH_LEN, hash of transaction
33
*/
34
Transaction
*mempool_remove(
unsigned
char
*tx_hash);
35
36
/* Finds transaction corresponding to tx_hash
37
*
38
* Returns transaction pointer if found, NULL otherwise
39
*
40
* tx_hash: Buffer of length TX_HASH_LEN, hash of transaction
41
*/
42
Transaction
*mempool_find(
unsigned
char
*tx_hash);
43
44
/* Finds entry corresponding to tx_hash
45
*
46
* Returns entry if found, NULL otherwise
47
*
48
* tx_hash: Buffer of length TX_HASH_LEN, hash of transaction
49
*/
50
MemPool
*mempool_find_node(
unsigned
char
*tx_hash);
51
52
/*
53
Prints a mempool item with the associated id/hash from the hasmap
54
55
prefix: string to put in front of all print commands used for tabbing structure
56
*/
57
void
print_mempool(
MemPool
*mempool,
char
*prefix);
58
59
/*
60
Prints all transactions in mempool hashmap to stdout
61
62
prefix: string to put in front of all print commands used for tabbing structure
63
*/
64
void
print_mempool_hashmap(
char
*prefix);
MemPool
Definition:
mempool.h:8
Transaction
Definition:
base_tx.h:19
Generated by
1.9.3