electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit d61ccd4275c800e3c142ba8913e361ec1b923811
parent 0b4f64a7b95e73fa69ec75414b1b811aef909495
Author: ThomasV <thomasv@electrum.org>
Date:   Wed,  9 Nov 2016 13:23:10 +0100

throttle send_requests

Diffstat:
Mlib/interface.py | 11++++++-----
Mlib/wallet.py | 2++
2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/lib/interface.py b/lib/interface.py @@ -258,19 +258,20 @@ class Interface(util.PrintError): self.unsent_requests.append(args) def send_requests(self): - '''Sends all queued requests. Returns False on failure.''' + '''Sends queued requests. Returns False on failure.''' make_dict = lambda (m, p, i): {'method': m, 'params': p, 'id': i} - wire_requests = map(make_dict, self.unsent_requests) + n = 100 - len(self.unanswered_requests) + wire_requests = self.unsent_requests[0:n] try: - self.pipe.send_all(wire_requests) + self.pipe.send_all(map(make_dict, wire_requests)) except socket.error, e: self.print_error("socket error:", e) return False - for request in self.unsent_requests: + self.unsent_requests = self.unsent_requests[n:] + for request in wire_requests: if self.debug: self.print_error("-->", request) self.unanswered_requests[request[2]] = request - self.unsent_requests = [] return True def ping_required(self): diff --git a/lib/wallet.py b/lib/wallet.py @@ -774,6 +774,8 @@ class Abstract_Wallet(PrintError): from util import format_time if conf == 0: tx = self.transactions.get(tx_hash) + if not tx: + return 3, 'unknown' is_final = tx and tx.is_final() fee = self.tx_fees.get(tx_hash) if fee and self.network and self.network.dynfee(0):