forked from bcosorg/bcos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NonceCheck.h
52 lines (34 loc) · 990 Bytes
/
NonceCheck.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
41
42
43
44
45
46
47
48
49
50
51
52
#pragma once
#include <libdevcore/Common.h>
#include <libdevcore/Guards.h>
#include <libdevcore/CommonIO.h>
#include <boost/timer.hpp>
#include <thread>
#include <libethereum/Transaction.h>
#include <libethereum/Block.h>
#include <libethereum/BlockChain.h>
using namespace std;
using namespace dev::eth;
namespace dev
{
namespace eth
{
class NonceCheck
{
private:
std::unordered_map< std::string,bool > m_cache;
unsigned m_startblk;
unsigned m_endblk;
mutable SharedMutex m_lock;
std::string generateKey(Transaction const & _t);
public:
static u256 maxblocksize;
NonceCheck(){}
~NonceCheck() ;
void init(BlockChain const& _bc);
bool ok(Transaction const & _transaction,bool _needinsert=false/*如果不存在是否插入*/);
void updateCache(BlockChain const& _bc,bool _rebuild=false);
void delCache( Transactions const & _transcations);
};
}
}