-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathTxPool.h
executable file
·40 lines (32 loc) · 1.16 KB
/
TxPool.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef TX_TXPOOL_H
#define TX_TXPOOL_H
#include <string>
#include <vector>
#include <unordered_map>
#include <mutex>
#include "Transaction/Transaction.h"
#include "Block/Block.h"
#include "Transaction/TransactionError.h"
class TxPool {
private:
std::unordered_map<std::string, TransactionForNetwork> transactionList;
std::unordered_map<std::string, TxIn> txInputs;
bool isTxInputPresent(TxIn txIn);
bool isTxInputPresent(TransactionForNetwork* transaction);
public:
static TxPool& Instance(){
static TxPool instance;
return instance;
}
static std::mutex transactionListLock;
static std::mutex txInputsLock;
std::unordered_map<std::string, TransactionForNetwork> getTransactionList();
void setTransactionList(std::unordered_map<std::string, TransactionForNetwork> transactionList);
void popTransaction(std::vector<unsigned char> txId);
bool appendTransaction(TransactionForNetwork transaction, bool broadcast, TransactionError *transactionError);
void appendTransactionsFromBlock(Block* block);
uint32_t getTxCount();
TransactionForNetwork* popTransaction();
void cleanTxPool();
};
#endif //TX_TXPOOL_H