commit
9140c95a0c
5 changed files with 62 additions and 52 deletions
|
@ -47,7 +47,7 @@ class ClaimOutpoint(dict):
|
||||||
self['nout'] = nout
|
self['nout'] = nout
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "{}:{}".format(txid,nout)
|
return "{}:{}".format(self['txid'], self['nout'])
|
||||||
|
|
||||||
def __eq__(self, compare):
|
def __eq__(self, compare):
|
||||||
if isinstance(compare, dict):
|
if isinstance(compare, dict):
|
||||||
|
@ -67,7 +67,8 @@ def _catch_connection_error(f):
|
||||||
try:
|
try:
|
||||||
return f(*args)
|
return f(*args)
|
||||||
except socket.error:
|
except socket.error:
|
||||||
raise ValueError("Unable to connect to an lbrycrd server. Make sure an lbrycrd server " +
|
raise ValueError(
|
||||||
|
"Unable to connect to an lbrycrd server. Make sure an lbrycrd server " +
|
||||||
"is running and that this application can connect to it.")
|
"is running and that this application can connect to it.")
|
||||||
return w
|
return w
|
||||||
|
|
||||||
|
@ -90,8 +91,9 @@ class Wallet(object):
|
||||||
self.queued_payments = defaultdict(Decimal) # {address(string): amount(Decimal)}
|
self.queued_payments = defaultdict(Decimal) # {address(string): amount(Decimal)}
|
||||||
self.expected_balances = defaultdict(Decimal) # {address(string): amount(Decimal)}
|
self.expected_balances = defaultdict(Decimal) # {address(string): amount(Decimal)}
|
||||||
self.current_address_given_to_peer = {} # {Peer: address(string)}
|
self.current_address_given_to_peer = {} # {Peer: address(string)}
|
||||||
self.expected_balance_at_time = deque() # (Peer, address(string), amount(Decimal), time(datetime), count(int),
|
# (Peer, address(string), amount(Decimal), time(datetime), count(int),
|
||||||
# incremental_amount(float))
|
# incremental_amount(float))
|
||||||
|
self.expected_balance_at_time = deque()
|
||||||
self.max_expected_payment_time = datetime.timedelta(minutes=3)
|
self.max_expected_payment_time = datetime.timedelta(minutes=3)
|
||||||
self.stopped = True
|
self.stopped = True
|
||||||
|
|
||||||
|
@ -193,7 +195,8 @@ class Wallet(object):
|
||||||
d.addCallback(lambda _: set_next_manage_call())
|
d.addCallback(lambda _: set_next_manage_call())
|
||||||
|
|
||||||
def log_error(err):
|
def log_error(err):
|
||||||
log.error("Something went wrong during manage. Error message: %s", err.getErrorMessage())
|
log.error("Something went wrong during manage. Error message: %s",
|
||||||
|
err.getErrorMessage())
|
||||||
return err
|
return err
|
||||||
|
|
||||||
d.addErrback(log_error)
|
d.addErrback(log_error)
|
||||||
|
@ -213,14 +216,15 @@ class Wallet(object):
|
||||||
return LBRYcrdAddressQueryHandlerFactory(self)
|
return LBRYcrdAddressQueryHandlerFactory(self)
|
||||||
|
|
||||||
def reserve_points(self, identifier, amount):
|
def reserve_points(self, identifier, amount):
|
||||||
"""
|
"""Ensure a certain amount of points are available to be sent as
|
||||||
Ensure a certain amount of points are available to be sent as payment, before the service is rendered
|
payment, before the service is rendered
|
||||||
|
|
||||||
@param identifier: The peer to which the payment will ultimately be sent
|
@param identifier: The peer to which the payment will ultimately be sent
|
||||||
|
|
||||||
@param amount: The amount of points to reserve
|
@param amount: The amount of points to reserve
|
||||||
|
|
||||||
@return: A ReservedPoints object which is given to send_points once the service has been rendered
|
@return: A ReservedPoints object which is given to send_points
|
||||||
|
once the service has been rendered
|
||||||
"""
|
"""
|
||||||
rounded_amount = Decimal(str(round(amount, 8)))
|
rounded_amount = Decimal(str(round(amount, 8)))
|
||||||
#if peer in self.peer_addresses:
|
#if peer in self.peer_addresses:
|
||||||
|
@ -287,11 +291,13 @@ class Wallet(object):
|
||||||
rounded_amount = Decimal(str(round(amount, 8)))
|
rounded_amount = Decimal(str(round(amount, 8)))
|
||||||
assert(peer in self.current_address_given_to_peer)
|
assert(peer in self.current_address_given_to_peer)
|
||||||
address = self.current_address_given_to_peer[peer]
|
address = self.current_address_given_to_peer[peer]
|
||||||
log.info("expecting a payment at address %s in the amount of %s", str(address), str(rounded_amount))
|
log.info("expecting a payment at address %s in the amount of %s",
|
||||||
|
str(address), str(rounded_amount))
|
||||||
self.expected_balances[address] += rounded_amount
|
self.expected_balances[address] += rounded_amount
|
||||||
expected_balance = self.expected_balances[address]
|
expected_balance = self.expected_balances[address]
|
||||||
expected_time = datetime.datetime.now() + self.max_expected_payment_time
|
expected_time = datetime.datetime.now() + self.max_expected_payment_time
|
||||||
self.expected_balance_at_time.append((peer, address, expected_balance, expected_time, 0, amount))
|
self.expected_balance_at_time.append(
|
||||||
|
(peer, address, expected_balance, expected_time, 0, amount))
|
||||||
peer.update_stats('expected_points', amount)
|
peer.update_stats('expected_points', amount)
|
||||||
|
|
||||||
def update_peer_address(self, peer, address):
|
def update_peer_address(self, peer, address):
|
||||||
|
|
|
@ -8,9 +8,9 @@ def migrate_db(db_dir, start, end):
|
||||||
from lbrynet.db_migrator.migrate1to2 import do_migration
|
from lbrynet.db_migrator.migrate1to2 import do_migration
|
||||||
do_migration(db_dir)
|
do_migration(db_dir)
|
||||||
else:
|
else:
|
||||||
raise Exception("DB migration of version {} to {} is not available".format(current,current+1))
|
raise Exception(
|
||||||
|
"DB migration of version {} to {} is not available".format(current, current+1))
|
||||||
current += 1
|
current += 1
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -38,10 +38,14 @@ def migrate_blockchainname_db(db_dir):
|
||||||
|
|
||||||
# fill n as V1_UNSET_NOUT, Wallet.py will be responsible for filling in correct n
|
# fill n as V1_UNSET_NOUT, Wallet.py will be responsible for filling in correct n
|
||||||
for name, txid, sd_hash in name_metadata:
|
for name, txid, sd_hash in name_metadata:
|
||||||
mem_cursor.execute("insert into name_metadata values (?, ?, ?, ?) ", (name, txid, UNSET_NOUT, sd_hash))
|
mem_cursor.execute(
|
||||||
|
"insert into name_metadata values (?, ?, ?, ?) ",
|
||||||
|
(name, txid, UNSET_NOUT, sd_hash))
|
||||||
|
|
||||||
for claim_id, name, txid in claim_metadata:
|
for claim_id, name, txid in claim_metadata:
|
||||||
mem_cursor.execute("insert into claim_ids values (?, ?, ?, ?)", (claim_id, name, txid, UNSET_NOUT))
|
mem_cursor.execute(
|
||||||
|
"insert into claim_ids values (?, ?, ?, ?)",
|
||||||
|
(claim_id, name, txid, UNSET_NOUT))
|
||||||
temp_db.commit()
|
temp_db.commit()
|
||||||
|
|
||||||
new_name_metadata = mem_cursor.execute("select * from name_metadata").fetchall()
|
new_name_metadata = mem_cursor.execute("select * from name_metadata").fetchall()
|
||||||
|
|
|
@ -47,7 +47,7 @@ from lbrynet.core.Wallet import LBRYcrdWallet, LBRYumWallet
|
||||||
from lbrynet.core.looping_call_manager import LoopingCallManager
|
from lbrynet.core.looping_call_manager import LoopingCallManager
|
||||||
from lbrynet.core.server.BlobRequestHandler import BlobRequestHandlerFactory
|
from lbrynet.core.server.BlobRequestHandler import BlobRequestHandlerFactory
|
||||||
from lbrynet.core.server.ServerProtocol import ServerProtocolFactory
|
from lbrynet.core.server.ServerProtocol import ServerProtocolFactory
|
||||||
from lbrynet.core.Error import InsufficientFundsError, InvalidNameError, UnknownNameError
|
from lbrynet.core.Error import InsufficientFundsError, InvalidNameError
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
|
@ -57,7 +57,7 @@ class Wallet(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_claim_metadata_for_sd_hash(self, sd_hash):
|
def get_claim_metadata_for_sd_hash(self, sd_hash):
|
||||||
return "fakeuri", "faketxid"
|
return "fakeuri", "faketxid", "fakenout"
|
||||||
|
|
||||||
|
|
||||||
class PeerFinder(object):
|
class PeerFinder(object):
|
||||||
|
|
Loading…
Add table
Reference in a new issue