Commit Graph

289 Commits

Author SHA1 Message Date
Neil Booth
221f1222a6 Defer peer discovery 2018-07-24 09:20:45 +08:00
Neil Booth
316f642a08 Reduce memory footprint
- Use tuples in preference to lists
  They are always at least 11% smaller memory
  footprint, rising to 35% for short arrays
2018-07-24 09:15:35 +08:00
Neil Booth
7485d0aaf0 Retain the prevouts with each MemPoolTx 2018-07-24 08:21:58 +08:00
ghost43
45ccf8a64e fix mempool tx fee calculation typo (#531) 2018-07-23 20:31:52 +08:00
Neil Booth
7c01acdbf2 Remove comment 2018-07-23 17:26:51 +08:00
Neil Booth
b05cc4e78b Clean up fee histogram implementation
Much more efficient to just calculate it outright than try
and maintain datastructures
2018-07-23 17:26:42 +08:00
Neil Booth
3e535e47f4 Start peer discovery whilst syncing the mempool 2018-07-23 15:18:49 +08:00
Neil Booth
0963ce5230 Completely overhaul mempool sync logic
- highly concurrent and a lot more efficient than previously
- initial mempool sync should be much faster (feedback please)
- mempool processing no longer blocks client session handling
- uses less memory to store the mempool
- fixes an obscure bug where sometimes txs were dropped
- more robust, clean and easy to understand

Fixes #433
2018-07-23 15:18:04 +08:00
Neil Booth
21604cad15 Create a MemPoolTx object and use it 2018-07-22 23:19:35 +08:00
Neil Booth
4b3ceff0d2 Deserialize mempool txs in a thread 2018-07-22 22:18:54 +08:00
Neil Booth
9bd9476a54 Make mempool processing more properly asynchronous 2018-07-22 21:56:22 +08:00
Neil Booth
4da95dd853 Simplify refresh hashes loop 2018-07-22 16:57:30 +08:00
Neil Booth
821f907971 Put stats logging into its own task 2018-07-22 16:54:32 +08:00
Neil Booth
2c51b127de Clarify mempool's exported interface 2018-07-22 13:25:13 +08:00
Neil Booth
a9a69acaf3 Pass the daemon not chain_state to mempool constructor
The mempool as its own process would maintain its own daemon
2018-07-22 12:04:48 +08:00
Neil Booth
35506f6054 Make notifications properly async 2018-07-22 10:38:37 +08:00
Neil Booth
e568ee2488 Improve comments 2018-07-21 20:51:42 +08:00
Neil Booth
c715ae6249 Rework mempool and notification code
Clarifies the mempool interface to look more like what it
would in its own process
2018-07-21 20:45:27 +08:00
Neil Booth
3e8c413b77 In ChainState prepend private members with an underscore 2018-07-21 20:45:27 +08:00
Neil Booth
6cf7b049fa Require aiohttp >= 2.0 2018-07-21 20:45:27 +08:00
Neil Booth
74c5c3f817 Don't accept onion peers if we have no proxy 2018-07-20 19:03:34 +08:00
Neil Booth
f7c95986bf Fix failing test 2018-07-20 17:14:47 +08:00
Neil Booth
0c28136739 Remove dead code 2018-07-20 17:05:30 +08:00
Neil Booth
8e99d076b6 Logging tweaks 2018-07-20 16:43:15 +08:00
Neil Booth
ca3ba2b2d8 Rework mempool and BP<->prefretcher communication 2018-07-20 16:43:15 +08:00
Neil Booth
431989f0ea Label 1.6a 2018-07-20 15:07:23 +08:00
Neil Booth
530c7cac6f Clean up shutdown process of the block processor
- enables removal of executor code
- clarify flush guarantees
2018-07-20 15:06:28 +08:00
Neil Booth
41e734caeb Clean up controller interface with other parts 2018-07-20 12:40:57 +08:00
Neil Booth
bd636a75ad Clean up the process of opening the DBs, make asynchronous 2018-07-20 12:26:59 +08:00
Neil Booth
a019656a5e Make it clear where BlockProcessor is instantiated 2018-07-20 12:26:49 +08:00
Omar Cruz
227696636d Added Motion Coin mainnet (#528)
* Motion added
2018-07-19 17:41:20 +08:00
Neil Booth
023e463748 Prepare 1.6 2018-07-19 11:07:02 +08:00
Neil Booth
94d1f7a651 Save raw blocks to disk for reorg purposes
We used to rely on the daemon being able to return the
orphaned blocks, but some old daemon codebases are buggy
and fail to do so.

Fixes #258 #315 #479
2018-07-18 16:09:19 +08:00
Neil Booth
7ce91b1a43 Minor tweaks 2018-07-18 14:22:40 +08:00
Neil Booth
f5926cf865 Label as 1.6pre3 2018-07-18 14:07:08 +08:00
Neil Booth
391e69b66c Introduce ChainState object
- reduces the tangle of object dependencies
- rationalizes responsibilities
2018-07-18 14:05:39 +08:00
Neil Booth
53425ce585 Move task logic to Tasks object
This helps to rationalize the inter-object
dependencies.
2018-07-18 11:30:33 +08:00
Neil Booth
22b01d4dfb Move masternode cache.
It was mistakenly made a pylru cache...
Don't force non-Dash coins to carry the cache.
2018-07-18 11:30:33 +08:00
Neil Booth
9cf3b5358f Move raw_header to session manager
Ultimately this stuff belongs in a ChainState object.
2018-07-18 11:30:33 +08:00
Neil Booth
b7572ce9c0 More refactoring of controller
- remove the header cache - not needed for higher protocol versions
- simplify session notification; move to session manager
- move history cache to session manager
2018-07-18 09:20:14 +08:00
Neil Booth
c8c896a14c Minor tweaks. 2018-07-18 08:46:37 +08:00
ghost43
c7f3f7ac6d new protocol method: blockchain.transaction.id_from_pos (#524) 2018-07-18 08:35:34 +08:00
Neil Booth
60435c0c06 Fix peer discovery for protocol >= 1.4 2018-07-17 22:45:50 +08:00
Neil Booth
c7f6f3ede6 Move get_utxos to session 2018-07-17 22:12:41 +08:00
Neil Booth
c712d4be32 Fix session_count invocation
(thanks to nijel)
2018-07-17 20:29:14 +08:00
Neil Booth
a3d3bbe9a7 Move more code out of controller to sessions
Disable a test that will require significant work
2018-07-17 20:20:28 +08:00
Neil Booth
0b55a3f7f2 Mark as pre2 2018-07-17 18:23:53 +08:00
Neil Booth
e41d1db25c Create SessionManager class
Break out controller functionality for session management.
2018-07-17 18:14:55 +08:00
Neil Booth
c35c062780 Move more code to session class from controller 2018-07-17 16:47:00 +08:00
Neil Booth
063f1b2eff Move block_get_header and estimate_fee to session 2018-07-17 14:45:55 +08:00
Neil Booth
ca777ed427 Move three more methods from the controller to session 2018-07-17 11:56:26 +08:00
Neil Booth
3dbc10bca0 Move address handlers from controller to session 2018-07-17 11:44:15 +08:00
Neil Booth
4f99f254ea Move scripthash handlers from controller to session 2018-07-17 11:32:42 +08:00
Neil Booth
739bb687fc Convert PROTOCOL_MIN, PROTOCOL_MAX to tuples 2018-07-17 10:59:41 +08:00
Neil Booth
c790fd567c Move things from Controller to session class
which better belong there:

- PROTOCOL_MIN, PROTOCOL_MAX
- server_features()
- server_version_args()
- inline protocol_tuple()
2018-07-17 09:33:33 +08:00
Neil Booth
fdb34e7d25 Store session's protocol version as a tuple, not string 2018-07-17 09:16:57 +08:00
Neil Booth
5ba5d05add Protocol 1.4: only accept a single server.version message
- remove unused self.client_version
- coerce client_name to a str
2018-07-17 09:16:26 +08:00
Neil Booth
382fc5ed44 Improve logging of client version requests 2018-07-16 21:25:50 +08:00
Neil Booth
8630c9136c Have the header merkle cache handle reorgs
Cleanest to move the mc_cache to the block processor
2018-07-16 20:54:55 +08:00
Neil Booth
362499778a Prepare 1.6pre1 2018-07-16 19:18:36 +08:00
Neil Booth
061cac51a8 Implement merkle proof for blockchain.block.headers 2018-07-16 17:32:49 +08:00
Neil Booth
46d8e0c608 Implement merkle proofs for blockchain.block.header 2018-07-16 16:02:55 +08:00
Neil Booth
20884170e6 Remove raw argument to blockchain.headers.subscribe 2018-07-16 15:00:52 +08:00
Neil Booth
d390b38acf Add cache truncation and tests 2018-07-16 12:42:53 +08:00
Neil Booth
26d8026938 Increase merkle cache test coverage to 100% 2018-07-16 09:53:43 +08:00
Neil Booth
4168341857 Implement a markle cache with tests 2018-07-16 09:36:32 +08:00
Neil Booth
997a1be377 Prepare 1.5.2 2018-07-15 08:05:09 +08:00
Neil Booth
73a46df17f Remove hash_to_str 2018-07-14 21:48:58 +08:00
Neil Booth
3c3a1b7017 Fix thinko in prior
Rename function to prevent similar mistakes in future

Also hash_to_str -> hash_to_hex_str
2018-07-14 21:29:11 +08:00
Neil Booth
c22b7d455c Have server code use merkle library 2018-07-14 20:11:34 +08:00
Neil Booth
af45363eeb Add merkle library with tests 2018-07-14 19:44:10 +08:00
Neil Booth
70f8d7c4b9 Partial reversion of 2cb89814b6
Fixes #523

BU, XT and other coins based on older Core code require integers
not booleans
2018-07-14 14:24:52 +08:00
Neil Booth
e1e4129e17 Prepare 1.5.1 2018-07-13 18:13:09 +08:00
Neil Booth
27f1c2480d Update BCH peers 2018-07-13 18:06:15 +08:00
Neil Booth
d2e8fe7fa1 Update peer discovery code for protocol 1.3 2018-07-13 17:57:00 +08:00
Neil Booth
9d02b03ab1 Log Python interpreter version on startup 2018-07-13 16:41:01 +08:00
Neil Booth
cd85a49a47 Use our own logging, not aiorpcX's 2018-07-13 09:26:37 +08:00
Neil Booth
8a4f9e20ac Prepare 1.5 2018-07-12 16:03:07 +08:00
Neil Booth
d51f98e739 Create and use class_logger() utility function 2018-07-12 15:51:42 +08:00
Neil Booth
9534a83257 Log class name only from server script
Based on #518 by eukreign
2018-07-12 15:32:45 +08:00
Neil Booth
7c82d1fe5f blockchain.headers.subscribe: raw defaults to True in 1.3
Update docs for this and other omissions.
2018-07-12 11:23:18 +08:00
Neil Booth
7911f0d525 Remove blockchain.address.* methods from protocol 1.3+ 2018-07-12 11:00:57 +08:00
Neil Booth
c35ac6d9bb Deprecate blockchain.block.get_header as of protocol 1.3
Use new blockchain.block.header instead.
2018-07-12 00:31:49 +08:00
Lex Berezhny
71b3d30842 Server listening (#516)
* + server_listening Event in Controller (to know when server has fully started)
2018-07-11 08:50:10 +08:00
Lex Berezhny
f8ebcf35b4 Env accepts custom Coin class (#517)
* + support for passing an actual coin class to Env()

* unit test for Env() accept coin class

* doc string explaining optional Coin argument to Env and assert to make sure a coin is a Coin
2018-07-11 08:48:57 +08:00
Neil
c28b5af309
Export Controller and Env from the package (#515) 2018-07-10 14:17:49 +08:00
Lex Berezhny
45111898b3 make it easier to configure logging for electrumx (#514)
* make it easier to configure logging for electrumx
2018-07-10 11:17:42 +08:00
Lex Berezhny
ddae0079a7 + BitcoinCashRegtest coin class (#512) 2018-07-10 09:36:40 +08:00
Lex Berezhny
29289004e7 electrumx package (#511)
* moved wallet, server, lib into electrumx main module

* fixed imports and other path references affected by electrumx main package

* fixing formatting to pass the pycodetest on travis
2018-07-10 07:28:04 +08:00