forked from Bitcoin-ABC/bitcoin-abc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscriptcache.h
33 lines (23 loc) · 1.05 KB
/
scriptcache.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
// Copyright (c) 2017 - The Bitcoin Developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_SCRIPT_SCRIPTCACHE_H
#define BITCOIN_SCRIPT_SCRIPTCACHE_H
#include <uint256.h>
#include <cstdint>
class CTransaction;
// DoS prevention: limit cache size to 32MB (over 1000000 entries on 64-bit
// systems). Due to how we count cache size, actual memory usage is slightly
// more (~32.25 MB)
static const unsigned int DEFAULT_MAX_SCRIPT_CACHE_SIZE = 32;
// Maximum sig cache size allowed
static const int64_t MAX_MAX_SCRIPT_CACHE_SIZE = 16384;
/** Initializes the script-execution cache */
void InitScriptExecutionCache();
/** Compute the cache key for a given transaction and flags. */
uint256 GetScriptCacheKey(const CTransaction &tx, uint32_t flags);
/** Check if a given key is in the cache. */
bool IsKeyInScriptCache(uint256 key, bool erase);
/** Add an entry in the cache. */
void AddKeyInScriptCache(uint256 key);
#endif // BITCOIN_SCRIPT_SCRIPTCACHE_H