diff --git a/docs/ARCHITECTURE.rst b/docs/ARCHITECTURE.rst index 98c43c4..81d9800 100644 --- a/docs/ARCHITECTURE.rst +++ b/docs/ARCHITECTURE.rst @@ -15,13 +15,13 @@ The components of the server are roughly like this:: - ElectrumX -<<<<<- LocalRPC - ------------- ------------ < > - ---------- ------------------- -------------- - - Daemon -<<<<<<<<- Block processor ->>>>- UTXO Cache - - ---------- ------------------- -------------- - < < > < - -------------- ---------------- - - Prefetcher - - FS + Storage - - -------------- ---------------- + ---------- ------------------- + - Daemon -<<<<<<<<- Block processor - + ---------- ------------------- + < < > + -------------- ----------- + - Prefetcher - - FS + DB - + -------------- ----------- Env @@ -60,22 +60,15 @@ Block Processor Responsible for managing block chain state (UTXO set, history, transaction and undo information) and processing towards the chain -tip. Uses the caches for in-memory state caching. Flushes state to -the storage layer. Reponsible for handling block chain -reorganisations. Once caught up maintains a representation of daemon -mempool state. +tip. Uses the caches for in-memory state updates since the last +flush. Flushes state to the storage layer. Reponsible for handling +block chain reorganisations. Once caught up maintains a +representation of daemon mempool state. -Caches ------- - -The file system cache and the UTXO cache are implementation details of -the block processor, nothing else should interface with them. - -Storage -------- +Database +-------- -Backend database abstraction. Along with the host filesystem, used by -the block processor (and therefore its caches) to store chain state. +The database. Along with the host filesystem stores flushed chain state. Prefetcher ---------- diff --git a/docs/RELEASE-NOTES b/docs/RELEASE-NOTES index aea65ec..ecdc22d 100644 --- a/docs/RELEASE-NOTES +++ b/docs/RELEASE-NOTES @@ -1,3 +1,10 @@ +Version 0.2.3 +------------- + +- fixes issues #6, #11, #15 +- the UTXO cache is now merged with BlockProcessor, where it properly belongs. + cache.py no longer exists + Version 0.2.2.1 --------------- diff --git a/server/block_processor.py b/server/block_processor.py index 1eee6b1..288f558 100644 --- a/server/block_processor.py +++ b/server/block_processor.py @@ -18,7 +18,6 @@ from bisect import bisect_left from collections import defaultdict from functools import partial -from server.cache import UTXOCache, NO_CACHE_ENTRY from server.daemon import Daemon, DaemonError from lib.hash import hash_to_str from lib.tx import Deserializer @@ -26,6 +25,13 @@ from lib.util import chunks, LoggedClass import server.db from server.storage import open_db +# Limits single address history to ~ 65536 * HIST_ENTRIES_PER_KEY entries +HIST_ENTRIES_PER_KEY = 1024 +HIST_VALUE_BYTES = HIST_ENTRIES_PER_KEY * 4 +ADDR_TX_HASH_LEN = 4 +UTXO_TX_HASH_LEN = 4 +NO_HASH_168 = bytes([255]) * 21 +NO_CACHE_ENTRY = NO_HASH_168 + bytes(12) def formatted_time(t): '''Return a number of seconds as a string in days, hours, mins and @@ -175,7 +181,7 @@ class MemPool(LoggedClass): ''' hex_hashes = set(hex_hashes) touched = set() - missing_utxos = 0 + missing_utxos = [] initial = self.count < 0 if initial: @@ -208,7 +214,7 @@ class MemPool(LoggedClass): # The mempool is unordered, so process all outputs first so # that looking for inputs has full info. script_hash168 = self.bp.coin.hash168_from_script - utxo_lookup = self.bp.utxo_cache.lookup + utxo_lookup = self.bp.utxo_lookup def txout_pair(txout): return (script_hash168(txout.pk_script), txout.value) @@ -229,6 +235,7 @@ class MemPool(LoggedClass): if entry == NO_CACHE_ENTRY: # This happens when the daemon is a block ahead of us # and has mempool txs spending new txs in that block + missing_utxos.append(txin) raise MissingUTXOError value, = struct.unpack('= 3.5.3 - ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2) - ssl_context.load_cert_chain(env.ssl_certfile, - keyfile=env.ssl_keyfile) - ssl_server = loop.create_server(protocol, env.host, env.ssl_port, - ssl=ssl_context) - self.servers.append(await ssl_server) - self.logger.info('SSL server listening on {}:{:d}' - .format(env.host, env.ssl_port)) + sslc = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2) + sslc.load_cert_chain(env.ssl_certfile, keyfile=env.ssl_keyfile) + await self.start_server('SSL', protocol, env.host, env.ssl_port, + ssl=sslc) def stop(self): '''Close the listening servers.''' diff --git a/server/version.py b/server/version.py index e6541a2..cf6e859 100644 --- a/server/version.py +++ b/server/version.py @@ -1 +1 @@ -VERSION = "ElectrumX 0.2.2.1" +VERSION = "ElectrumX 0.2.3"