Commit Graph

236 Commits

Author SHA1 Message Date
Neil Booth
86626d8080 Consistency in handling of self.interface
switch_to_interface() becomes the common place where
self.interface is set; therefore self.interface is not None
precisely when self.default_server is connected.  Previously some
places required it to be connected and some didn't.  Also an
interface change now sends the 'updated' notification
consistently - previously some did and some didn't.

Have network_start() call start_interfaces() - this also means
network restarts now do this.

Fix apparent off-by-one in start_interfaces()
2015-05-22 09:13:09 +09:00
Neil Booth
c918e74039 Put common network start and stop code in one place.
Prefer to use safer self.is_connected() as it checks interface
is not None.

Using common code gives small observable changes in behaviour:

 - slightly different print_error() messages
 - network restarts now enter status 'connecting' which they
   didn't before, which seems correct
 - status 'connecting' is done with set_status() rather than
   simply assigning the status, which seems more correct.  Now
   that the response_queue is available in the constructor this
   works; it used to fail with 'response_queue is not defined'
2015-05-22 07:52:59 +09:00
ThomasV
8620019f92 Merge pull request #1222 from kyuupichan/if_notification
Put interface notification handling in its own function.
2015-05-21 15:05:07 +02:00
ThomasV
5bd22d2378 follow-up to bd781d600b: use pipe 2015-05-21 12:50:26 +02:00
Neil Booth
c9a30eb5f2 Put interface notification handling in its own function. 2015-05-21 17:45:37 +09:00
Neil Booth
bd781d600b Have queues passed to the network constructor.
This is somewhat cleaner as the proxy's pipe and network setup
was awkwardly interleaved.  It also means network's constructor
is free to use both; currently some code is working around the
fact that the response queue doesn't exist in the constructor.
2015-05-21 12:49:39 +09:00
ThomasV
2104e96a66 network: use get_nowait on one of the two queues 2015-05-19 10:22:25 +02:00
Neil Booth
63733ccd2a No need for thread to handle requests
Handle requests in the main loop.
Remove unused lock.
interface.py was reworked and send_request() no longer throws.
2015-05-19 14:29:10 +09:00
ThomasV
e33bc2473b network: don't store unanswered request if result is in cache 2015-05-17 09:00:36 +02:00
ThomasV
6d0bc5d9b3 fix: nodes retry 2015-05-17 08:41:01 +02:00
ThomasV
44f06de796 network: when interface is disconnected, clear cache and resend unanswered requests 2015-05-15 14:47:59 +02:00
ThomasV
a1d1999545 move interfaces maintenance to its own function 2015-05-08 20:13:18 +02:00
ThomasV
f2c2f9d738 network: fix confusion between addresses and cached responses 2015-05-08 17:59:33 +02:00
ThomasV
233fd8ed77 revert 175bfae9e6. store last known height in wallet instead 2015-05-08 13:43:42 +02:00
ThomasV
ffda5cd866 Merge pull request #1187 from kyuupichan/local_height
Move away from requiring network and blockchain objects to be able to re...
2015-05-06 17:45:42 +02:00
Neil Booth
c07e956127 Pass the response_queue to the constructor, not start().
Removes an unnecessary Thread base-class override.  The python
documentation also strongly discourages overriding anything other
than run().
2015-05-05 20:37:25 +09:00
Neil Booth
9cf2eff16b Make is_connected into a member function. No change in logic. 2015-05-05 20:00:10 +09:00
Neil Booth
175bfae9e6 Move away from requiring network and blockchain objects to be able to request local height.
We store it in the config object instead of in the blockchain object.
The blockchain object now refers to its config, and calls refresh_height() to update it.
The network objects also refer to the config rather than the blockchain.

This is the first of many small steps to untangle the verifier from stored state and so
permit the history tab to work in offline mode.  The refactoring will simultaneously clean
up a lot of accumulated cruft.
2015-05-03 15:19:29 +09:00
ThomasV
cdd5d6e130 fix #1136 2015-04-09 19:05:11 +02:00
ThomasV
911a60c02d separate timeouts for server and nodes retry 2015-04-02 15:12:01 +02:00
ThomasV
98cc9c53d1 do not write config file from network class 2015-04-02 10:50:09 +02:00
ThomasV
a805afa900 save recent_servers in separate file 2015-04-02 10:12:51 +02:00
ThomasV
cf0fcac9fa fix deserialize_server bug 2015-03-28 19:17:07 +01:00
ThomasV
a4cb70649d fix synchronizer hanging when not connected. 2015-03-14 08:43:43 +01:00
ThomasV
72688a5cfa clean implementation of daemon threads 2015-03-13 23:04:29 +01:00
ThomasV
9e4eda24b5 fix #1082 2015-03-13 12:00:08 +01:00
ThomasV
f32f1183fc print_error methods. request timeout for interface 2015-03-12 21:39:05 +01:00
ThomasV
1569cd0420 serialize/deserialize methods for servers 2015-03-12 18:06:28 +01:00
ThomasV
c4d0314817 network: separate interface management from reconnection logic 2015-03-12 17:44:16 +01:00
ThomasV
799a08514b move proxy logic to network.py. reload socket module if proxy is disabled 2015-03-12 12:56:06 +01:00
ThomasV
0947eb7960 should test proxy_str. fixes issue #1073 2015-03-10 09:05:44 +01:00
ThomasV
73d8ba24d9 fix network connection issues 2015-03-07 22:47:25 +01:00
ThomasV
e9b06f494d abort set_parameters if changes are not allowed by config 2015-03-01 07:27:05 +01:00
ThomasV
7a9141e509 deserialize network.proxy to prevent variability 2015-02-28 20:04:03 +01:00
ThomasV
510934d545 do not store protocol explicitly 2015-02-28 15:37:50 +01:00
ThomasV
f489466709 fix: notify proxy when switching server 2015-02-28 14:08:58 +01:00
ThomasV
761871b900 sanitize server and protocol 2015-02-25 17:14:31 +01:00
ThomasV
e389745491 remove appdata_dir and data_dir 2015-02-18 18:48:32 +01:00
ThomasV
03a88743a3 fix typo: stdout 2015-02-11 21:05:33 +01:00
ThomasV
3c6cfc8b70 disable server selector if server is passed from cmd line 2015-01-29 13:35:19 +01:00
ThomasV
8ca17a3e70 print traceback is an exception occurs in network.process_request 2015-01-29 11:32:58 +01:00
ThomasV
30763a6555 fix config: serialize/deserialize proxy 2015-01-29 11:21:17 +01:00
Tafelpoot
d9c5250a6f removed trailing whitespace and fixed indentation in history widget 2014-10-21 19:05:51 +02:00
ThomasV
b8f971fcd6 force reconnect after delay 2014-09-16 12:21:01 +02:00
ThomasV
90590f70ab reconnect to main server after timeout 2014-09-14 14:27:39 +02:00
Eagle[TM]
a7cd8b5e9f Update default server list 2014-08-19 14:41:27 +02:00
ThomasV
854f49fbed fix number of interfaces being opened 2014-08-17 11:48:46 +02:00
ThomasV
ecdb90b0b7 re-use pending_servers to avoid sending unnecessary notifications 2014-08-04 11:29:58 +02:00
ThomasV
642258ebaa notify about interfaces 2014-07-30 11:27:52 +02:00
ThomasV
858ff86660 network: disconnected retry interval 2014-07-30 10:43:15 +02:00
ThomasV
ec5478c328 don't use pending_servers 2014-07-30 10:19:15 +02:00
ThomasV
517f649532 fix: missing break 2014-07-29 17:53:31 +02:00
ThomasV
0240b8c924 fix switch_to_random_interface 2014-07-29 14:26:19 +02:00
ThomasV
411a87e0a3 fix disconnection error 2014-07-29 14:19:23 +02:00
ThomasV
1c707d05d3 rm wrong assert clause 2014-07-29 12:48:05 +02:00
ThomasV
58c817f81a close interfaces on shutdown 2014-07-29 12:13:21 +02:00
ThomasV
ed8f9666df remove interface.synchronous_get 2014-07-29 00:15:21 +02:00
ThomasV
312051a242 one more daemon thread 2014-07-28 15:49:41 +02:00
ThomasV
fb0574c5a0 fix callbacks 2014-07-28 07:53:02 +02:00
ThomasV
1ee4af8686 fix #778 2014-07-28 06:42:05 +02:00
ThomasV
28df27fba2 update interface.py 2014-07-28 00:13:40 +02:00
ThomasV
035ecbc7cd redo inter-thread communication using pipes 2014-07-27 17:13:46 +02:00
ThomasV
7abbf329b6 fix 2014-07-25 20:14:08 +02:00
ThomasV
af3fd62fd4 send server height and server lag with daemon 2014-07-25 16:32:19 +02:00
ThomasV
2120b1a573 command line: wait until daemon is connected 2014-07-25 13:30:27 +02:00
ThomasV
8196bc5779 adapt network dialog to daemon 2014-07-25 09:11:56 +02:00
ThomasV
09e4efc439 daemon notifications (network.status) 2014-07-24 23:17:06 +02:00
ThomasV
9ee0614edb make daemon usable with the GUI 2014-07-24 16:12:18 +02:00
Chris Glass
8997c760a2 Do not use mutables as default values!
This blog article explains why (just an example, many other articles
discuss this ad nauseam):
http://pythonconquerstheuniverse.wordpress.com/2012/02/15/mutable-default-arguments/
2014-06-25 17:43:45 +02:00
ThomasV
173c034e26 on_header: return early if block_height is missing 2014-06-12 15:49:53 +02:00
ThomasV
80a988e337 slightly better notifications. at least, it fixes #652 2014-04-17 17:38:21 +02:00
Eagle[TM]
e81385fc05 update server list 2014-03-16 12:18:38 +01:00
ThomasV
32cca276fe don't use recent_servers if list from irc is available 2014-03-13 19:23:26 +01:00
ThomasV
f3b728989a update default servers 2014-03-13 14:07:36 +01:00
ThomasV
960e7bc3df fix reference to verifier 2014-03-11 09:38:08 +01:00
ThomasV
b4bed1ccaa remove blockchain object from verifier 2014-03-10 20:53:05 +01:00
ThomasV
6e30894af6 daemon; initial commit 2014-03-10 16:16:27 +01:00
ThomasV
3c4fa06c10 parse_servers 2014-02-11 09:48:02 +01:00
ThomasV
268a099f87 sync_get 2014-01-29 16:48:00 +01:00
ThomasV
d15c4f1046 store merkle roots and utxo roots 2014-01-27 10:37:39 +01:00
ThomasV
7c6bc72cb4 daemon 2014-01-27 10:37:39 +01:00
ThomasV
d4fbe85d7d json rpc daemon 2014-01-27 10:37:39 +01:00
ThomasV
36a6deaee7 renamed server. fixes issue #508 2013-12-25 16:26:15 +01:00
ThomasV
de94eaadeb fix issue occuring with set_server 2013-12-17 18:20:54 +01:00
ecdsa
ae654b30b9 fix: pending_servers 2013-12-16 20:07:35 +01:00
ecdsa
8140d6c78e fix typo 2013-12-16 20:04:59 +01:00
ecdsa
d140383d03 exit wait_until_connected() when all servers have been tried 2013-12-16 19:59:35 +01:00
ThomasV
4446cf44c7 don't set network.interface to None when disconnetced 2013-12-16 19:18:57 +01:00
thomasv
942d009661 network.pending_servers, to avoid connecting the same server multiple times 2013-12-16 18:17:44 +01:00
thomasv
c7694a87e7 cleanup code in network.py 2013-12-16 17:37:32 +01:00
ecdsa
8b4410d86a detect if electrum is offline during wallet creation 2013-12-14 10:20:40 +01:00
Jud Stephenson
03a6791bcb Set initial 'running' attribute in Network class
This was causing a AttributeError when network.is_running() was called before the network was started.
2013-12-08 17:08:06 -05:00
ThomasV
1f13b2f4f3 network.send method 2013-11-11 16:18:40 +01:00
ThomasV
ff647c79fd Merge pull request #374 from nolith/master
allow to connect to one server only
2013-11-10 02:55:33 -08:00
Bryan Stitt
225d8b83a3 don't use bare except 2013-11-09 21:23:57 -08:00
Eagle[TM]
ba9782eec6 Update default server list (disable servers with failed/expired certs) 2013-11-10 01:26:06 +01:00
Alessio Caiazza
423ed77305 allow to connect to one server only
This changeset allow to disable block headers retrieval from multiple
servers.
2013-11-06 18:02:37 +01:00
ThomasV
c2f2ec2a8c rm debug message 2013-11-03 11:06:57 +01:00
Eagle[TM]
dca000568f Update default server list 2013-10-17 01:44:21 +02:00
ThomasV
116b10cc11 replace blockchain.height with height(), and fix server_lag issue 2013-10-09 10:04:32 +02:00
ThomasV
491aab4afc network.default_server shouldnever be None 2013-10-08 16:52:50 +02:00
thomasv
e256bae89c re-add pick_random_server 2013-10-07 16:07:44 +02:00
ThomasV
66f224eab4 update a few scripts 2013-10-06 12:28:45 +02:00
ThomasV
f74aa9ed3a smaller timeout if disconnected 2013-10-05 15:31:39 +02:00
ThomasV
45b111e14c enable changes of protocol, proxy at runtime 2013-10-05 13:48:02 +02:00
ThomasV
a6934f6796 support for all protocols 2013-10-05 11:16:09 +02:00
ThomasV
9c1b688e4f fix: server lag 2013-10-05 11:02:17 +02:00
ThomasV
bc15caa84c network: fix server lag detection 2013-10-05 10:01:33 +02:00
ThomasV
c0abd3c34e show lag in status line 2013-10-05 00:49:24 +02:00
ThomasV
a38298c5ee handle network.interface being None when network is disconnected 2013-10-04 19:27:50 +02:00
ThomasV
c63948b314 update default servers 2013-10-04 14:37:15 +02:00
ThomasV
c0b3aed48b store a list of recently encountered servers 2013-10-04 14:30:23 +02:00
ThomasV
b1273d3900 network.is_connected() 2013-10-04 13:51:46 +02:00
ThomasV
a9fb0a9d19 resend subscriptions after disconnect 2013-10-04 11:13:05 +02:00
ThomasV
81f24b66c4 maintain NUM_SERVERS interfaces 2013-10-04 10:38:03 +02:00
ThomasV
7a5016ec42 move synchronous_get to network.py, fix get_balance script 2013-10-03 10:05:01 +02:00
ThomasV
56917780f1 server name change (hachre) 2013-10-02 13:50:56 +02:00
ThomasV
40e393187a manage subscriptions in network.py 2013-10-02 13:00:02 +02:00
ThomasV
a22ae33a81 set_server: resend subscriptions 2013-10-02 12:13:07 +02:00
ThomasV
27cc09e8e2 prevent dns leaks when using proxy. fixes issue #147 2013-10-01 11:24:55 +02:00
ThomasV
7658b2ade1 interface: call socket.connect before sll.wrap_socket, for proxy. (fixes bug #207) 2013-10-01 09:01:46 +02:00
thomasv
a6002cf71c SSL certificate validation 2013-09-30 14:01:49 +02:00
ThomasV
d502b93872 network.set_server: test if server is the same 2013-09-27 13:15:57 +02:00
rofl0r
854802122c fix error to create a wallet due to missing pick_random_server decl 2013-09-18 16:55:19 +00:00
thomasv
b75f8d795a new command: getrawtransaction 2013-09-15 11:19:48 +02:00
ThomasV
41878dc5e0 rename menu: create tx 2013-09-15 09:03:45 +02:00
ThomasV
d51a8d0f25 create a class for transaction dialog 2013-09-14 21:07:54 +02:00
thomasv
dcedb2d74f minor fixes 2013-09-13 13:56:33 +02:00
thomasv
6b6c508976 replace wallet.interface everywhere 2013-09-12 14:58:42 +02:00
ThomasV
907dca6eb9 simplify interface: use callbacks 2013-09-12 08:41:27 +02:00
thomasv
77871b97af fixes, resend_subscriptions 2013-09-10 19:59:58 +02:00
thomasv
73901a001a pass network to NetworkDialog and Blockchain 2013-09-10 18:27:32 +02:00
thomasv
2df129cfbf connect to random servers, reconnect if connection is lost 2013-09-10 17:52:43 +02:00
thomasv
0ec436c02c fix: network start was calling __init__ 2013-09-10 16:42:11 +02:00
thomasv
047e4b3478 move callbacks to the network class 2013-09-09 13:33:25 +02:00
ThomasV
328315f94b separate blockchain and network 2013-09-08 17:23:01 +02:00