don't delete lock if it's not in locks dict and other fun things
This commit is contained in:
parent
e36e4c6354
commit
97532fb300
3 changed files with 14 additions and 7 deletions
|
@ -55,12 +55,18 @@ class MainNetTestLedger(MainNetLedger):
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
class TestSynchronization(unittest.TestCase):
|
class LedgerTestCase(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.ledger = MainNetTestLedger()
|
self.ledger = MainNetTestLedger()
|
||||||
return self.ledger.db.start()
|
return self.ledger.db.start()
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
return self.ledger.db.stop()
|
||||||
|
|
||||||
|
|
||||||
|
class TestSynchronization(LedgerTestCase):
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def test_update_history(self):
|
def test_update_history(self):
|
||||||
account = self.ledger.account_class.generate(self.ledger, u"torba")
|
account = self.ledger.account_class.generate(self.ledger, u"torba")
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
|
|
||||||
import torba.baseledger
|
|
||||||
from torba.mnemonic import Mnemonic
|
from torba.mnemonic import Mnemonic
|
||||||
from torba.bip32 import PrivateKey, PubKey, from_extended_key_string
|
from torba.bip32 import PrivateKey, PubKey, from_extended_key_string
|
||||||
from torba.hash import double_sha256, aes_encrypt, aes_decrypt
|
from torba.hash import double_sha256, aes_encrypt, aes_decrypt
|
||||||
|
|
|
@ -90,8 +90,9 @@ class BaseLedger(six.with_metaclass(LedgerRegistry)):
|
||||||
def get_id(cls):
|
def get_id(cls):
|
||||||
return '{}_{}'.format(cls.symbol.lower(), cls.network_name.lower())
|
return '{}_{}'.format(cls.symbol.lower(), cls.network_name.lower())
|
||||||
|
|
||||||
def hash160_to_address(self, h160):
|
@classmethod
|
||||||
raw_address = self.pubkey_address_prefix + h160
|
def hash160_to_address(cls, h160):
|
||||||
|
raw_address = cls.pubkey_address_prefix + h160
|
||||||
return Base58.encode(bytearray(raw_address + double_sha256(raw_address)[0:4]))
|
return Base58.encode(bytearray(raw_address + double_sha256(raw_address)[0:4]))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -100,8 +101,9 @@ class BaseLedger(six.with_metaclass(LedgerRegistry)):
|
||||||
prefix, pubkey_bytes, addr_checksum = bytes[0], bytes[1:21], bytes[21:]
|
prefix, pubkey_bytes, addr_checksum = bytes[0], bytes[1:21], bytes[21:]
|
||||||
return pubkey_bytes
|
return pubkey_bytes
|
||||||
|
|
||||||
def public_key_to_address(self, public_key):
|
@classmethod
|
||||||
return self.hash160_to_address(hash160(public_key))
|
def public_key_to_address(cls, public_key):
|
||||||
|
return cls.hash160_to_address(hash160(public_key))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def private_key_to_wif(private_key):
|
def private_key_to_wif(private_key):
|
||||||
|
@ -303,7 +305,7 @@ class BaseLedger(six.with_metaclass(LedgerRegistry)):
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
lock.release()
|
lock.release()
|
||||||
if not lock.locked:
|
if not lock.locked and hex_id in self._transaction_processing_locks:
|
||||||
del self._transaction_processing_locks[hex_id]
|
del self._transaction_processing_locks[hex_id]
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
|
Loading…
Reference in a new issue