forked from LBRYCommunity/lbry-sdk
Merge branch 'master' into fix_descriptor_get
This commit is contained in:
commit
c66225ccf8
13 changed files with 82 additions and 73 deletions
|
@ -1,5 +1,5 @@
|
|||
[bumpversion]
|
||||
current_version = 0.9.1rc4
|
||||
current_version = 0.9.1
|
||||
commit = True
|
||||
tag = True
|
||||
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)((?P<release>[a-z]+)(?P<candidate>\d+))?
|
||||
|
|
20
CHANGELOG.md
20
CHANGELOG.md
|
@ -9,19 +9,35 @@ at anytime.
|
|||
|
||||
## [Unreleased]
|
||||
### Added
|
||||
* publish API command can take metadata fields as arguments
|
||||
* Add `wallet_list` command
|
||||
*
|
||||
*
|
||||
|
||||
### Changed
|
||||
*
|
||||
* Dont add expected payment to wallet when payment rate is 0
|
||||
*
|
||||
*
|
||||
|
||||
### Fixed
|
||||
* Fixed descriptor_get
|
||||
* Fixed jsonrpc_reflect()
|
||||
* Fixed api help return
|
||||
* Fixed API command descriptor_get
|
||||
*
|
||||
*
|
||||
*
|
||||
|
||||
## [0.9.1] - 2017-03-17
|
||||
### Fixed
|
||||
* Fix wallet_public_key API command
|
||||
|
||||
## [0.9.1rc5] - 2017-03-16
|
||||
### Added
|
||||
* publish API command can take metadata fields as arguments
|
||||
* Added `reflect_uploads` config to disable reflecting on upload
|
||||
### Fixed
|
||||
* Fixed jsonrpc_reflect()
|
||||
* Fixed api help return
|
||||
|
||||
## [0.9.1rc2] - 2017-03-15
|
||||
### Added
|
||||
|
|
|
@ -633,8 +633,9 @@ Returns:
|
|||
Get public key from wallet address
|
||||
|
||||
Args:
|
||||
'wallet': (str) wallet address in base58
|
||||
'address': (str) wallet address in base58
|
||||
Returns:
|
||||
(str) Public key in hex encoding
|
||||
(list) list of public keys associated with address.
|
||||
Could contain more than one public key if multisig.
|
||||
```
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import logging
|
||||
|
||||
__version__ = "0.9.1rc4"
|
||||
__version__ = "0.9.1"
|
||||
version = tuple(__version__.split('.'))
|
||||
|
||||
logging.getLogger(__name__).addHandler(logging.NullHandler())
|
||||
|
|
|
@ -19,9 +19,10 @@ def log_response(fn):
|
|||
elif future.exception():
|
||||
exc, traceback = future.exception_info()
|
||||
log.warning('Failed to send an analytics event', exc_info=(type(exc), exc, traceback))
|
||||
else:
|
||||
response = future.result()
|
||||
log.debug('Response (%s): %s', response.status_code, response.content)
|
||||
# GRIN TURNED THIS OFF. Segment only has one response: {"success": true}
|
||||
# else:
|
||||
# response = future.result()
|
||||
# log.debug('Response (%s): %s', response.status_code, response.content)
|
||||
|
||||
@functools.wraps(fn)
|
||||
def wrapper(*args, **kwargs):
|
||||
|
|
|
@ -192,7 +192,7 @@ ADJUSTABLE_SETTINGS = {
|
|||
'peer_port': (int, 3333),
|
||||
'pointtrader_server': (str, 'http://127.0.0.1:2424'),
|
||||
'reflector_port': (int, 5566),
|
||||
'reflector_reupload': (bool, True),
|
||||
'reflect_uploads': (bool, True),
|
||||
'reflector_servers': (list, [('reflector.lbry.io', 5566)], server_port),
|
||||
'run_on_startup': (bool, False),
|
||||
'run_reflector_server': (bool, False),
|
||||
|
|
|
@ -1101,8 +1101,13 @@ class LBRYumWallet(Wallet):
|
|||
def _address_is_mine(self, address):
|
||||
return self._run_cmd_as_defer_succeed('ismine', address)
|
||||
|
||||
def get_pub_keys(self, wallet):
|
||||
return self._run_cmd_as_defer_succeed('getpubkyes', wallet)
|
||||
# returns a list of public keys associated with address
|
||||
# (could be multiple public keys if a multisig address)
|
||||
def get_pub_keys(self, address):
|
||||
return self._run_cmd_as_defer_succeed('getpubkeys', address)
|
||||
|
||||
def list_addresses(self):
|
||||
return self._run_cmd_as_defer_succeed('listaddresses')
|
||||
|
||||
def _save_wallet(self, val):
|
||||
self.wallet.storage.write()
|
||||
|
|
|
@ -5,12 +5,10 @@ from twisted.protocols.basic import FileSender
|
|||
from twisted.python.failure import Failure
|
||||
from zope.interface import implements
|
||||
|
||||
|
||||
from lbrynet.core.Offer import Offer
|
||||
from lbrynet import analytics
|
||||
from lbrynet.interfaces import IQueryHandlerFactory, IQueryHandler, IBlobSender
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -212,11 +210,14 @@ class BlobRequestHandler(object):
|
|||
|
||||
def set_expected_payment():
|
||||
log.debug("Setting expected payment")
|
||||
if self.blob_bytes_uploaded != 0 and self.blob_data_payment_rate is not None:
|
||||
if (
|
||||
self.blob_bytes_uploaded != 0 and self.blob_data_payment_rate is not None
|
||||
and self.blob_data_payment_rate > 0
|
||||
):
|
||||
# TODO: explain why 2**20
|
||||
self.wallet.add_expected_payment(self.peer,
|
||||
self.currently_uploading.length * 1.0 *
|
||||
self.blob_data_payment_rate / 2**20)
|
||||
self.blob_data_payment_rate / 2 ** 20)
|
||||
self.blob_bytes_uploaded = 0
|
||||
self.peer.update_stats('blobs_uploaded', 1)
|
||||
return None
|
||||
|
|
|
@ -17,6 +17,7 @@ from lbrynet.lbryfile.StreamDescriptor import EncryptedFileStreamType
|
|||
from lbrynet.cryptstream.client.CryptStreamDownloader import AlreadyStoppedError
|
||||
from lbrynet.cryptstream.client.CryptStreamDownloader import CurrentlyStoppingError
|
||||
from lbrynet.core.sqlite_helpers import rerun_if_locked
|
||||
from lbrynet import conf
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -57,6 +58,7 @@ class EncryptedFileManager(object):
|
|||
yield self._open_db()
|
||||
yield self._add_to_sd_identifier()
|
||||
yield self._start_lbry_files()
|
||||
if conf.settings['reflect_uploads']:
|
||||
safe_start_looping_call(self.lbry_file_reflector)
|
||||
|
||||
def get_lbry_file_status(self, lbry_file):
|
||||
|
|
|
@ -774,6 +774,7 @@ class Daemon(AuthJSONRPCServer):
|
|||
claim_out = yield publisher.update_stream(name, bid, metadata)
|
||||
else:
|
||||
claim_out = yield publisher.publish_stream(name, file_path, bid, metadata)
|
||||
if conf.settings['reflect_uploads']:
|
||||
d = reupload.reflect_stream(publisher.lbry_file)
|
||||
d.addCallbacks(lambda _: log.info("Reflected new publication to lbry://%s", name),
|
||||
log.exception)
|
||||
|
@ -1217,29 +1218,11 @@ class Daemon(AuthJSONRPCServer):
|
|||
"""
|
||||
Get daemon settings
|
||||
|
||||
Args:
|
||||
None
|
||||
Returns:
|
||||
(dict) Dictionary of daemon settings
|
||||
{
|
||||
'run_on_startup': (bool) currently not supported
|
||||
'data_rate': (float) data rate
|
||||
'max_key_fee': (float) maximum key fee
|
||||
'download_directory': (str) path of where files are downloaded
|
||||
'max_upload': (float), currently not supported
|
||||
'max_download': (float), currently not supported
|
||||
'download_timeout': (int) download timeout in seconds
|
||||
'max_search_results': (int) max search results
|
||||
'wallet_type': (str) wallet type
|
||||
'delete_blobs_on_remove': (bool) delete blobs on removal
|
||||
'peer_port': (int) peer port
|
||||
'dht_node_port': (int) dht node port
|
||||
'use_upnp': (bool) use upnp if true
|
||||
}
|
||||
See ADJUSTABLE_SETTINGS in lbrynet/conf.py for full list of settings
|
||||
"""
|
||||
|
||||
log.info("Get daemon settings")
|
||||
return self._render_response(conf.settings.get_current_settings_dict())
|
||||
return self._render_response(conf.settings.get_adjustable_settings_dict())
|
||||
|
||||
@AuthJSONRPCServer.auth_required
|
||||
def jsonrpc_set_settings(self, **kwargs):
|
||||
|
@ -1249,6 +1232,7 @@ class Daemon(AuthJSONRPCServer):
|
|||
return self.jsonrpc_settings_set(**kwargs)
|
||||
|
||||
@AuthJSONRPCServer.auth_required
|
||||
@defer.inlineCallbacks
|
||||
def jsonrpc_settings_set(self, **kwargs):
|
||||
"""
|
||||
Set daemon settings
|
||||
|
@ -1261,22 +1245,14 @@ class Daemon(AuthJSONRPCServer):
|
|||
'max_upload': (float), currently not supported
|
||||
'max_download': (float), currently not supported
|
||||
'download_timeout': (int) download timeout in seconds
|
||||
'search_timeout': (float) search timeout in seconds
|
||||
'cache_time': (int) cache timeout in seconds
|
||||
Returns:
|
||||
(dict) settings dict
|
||||
(dict) Updated dictionary of daemon settings
|
||||
"""
|
||||
|
||||
def _log_settings_change():
|
||||
log.info(
|
||||
"Set daemon settings to %s",
|
||||
json.dumps(conf.settings.get_adjustable_settings_dict()))
|
||||
|
||||
d = self._update_settings(kwargs)
|
||||
d.addErrback(lambda err: log.info(err.getTraceback()))
|
||||
d.addCallback(lambda _: _log_settings_change())
|
||||
d.addCallback(
|
||||
lambda _: self._render_response(conf.settings.get_adjustable_settings_dict()))
|
||||
|
||||
return d
|
||||
yield self._update_settings(kwargs)
|
||||
defer.returnValue(conf.settings.get_adjustable_settings_dict())
|
||||
|
||||
def jsonrpc_help(self, command=None):
|
||||
"""
|
||||
|
@ -2005,18 +1981,36 @@ class Daemon(AuthJSONRPCServer):
|
|||
return self.jsonrpc_wallet_public_key(wallet)
|
||||
|
||||
@AuthJSONRPCServer.auth_required
|
||||
def jsonrpc_wallet_public_key(self, wallet):
|
||||
def jsonrpc_wallet_public_key(self, address):
|
||||
"""
|
||||
Get public key from wallet address
|
||||
|
||||
Args:
|
||||
'wallet': (str) wallet address in base58
|
||||
'address': (str) wallet address in base58
|
||||
Returns:
|
||||
(str) Public key in hex encoding
|
||||
(list) list of public keys associated with address.
|
||||
Could contain more than one public key if multisig.
|
||||
"""
|
||||
|
||||
d = self.session.wallet.get_pub_keys(wallet)
|
||||
d = self.session.wallet.get_pub_keys(address)
|
||||
d.addCallback(lambda r: self._render_response(r))
|
||||
return d
|
||||
|
||||
@AuthJSONRPCServer.auth_required
|
||||
@defer.inlineCallbacks
|
||||
def jsonrpc_wallet_list(self):
|
||||
"""
|
||||
List wallet addresses
|
||||
|
||||
Args:
|
||||
None
|
||||
Returns:
|
||||
List of wallet addresses
|
||||
"""
|
||||
|
||||
addresses = yield self.session.wallet.list_addresses()
|
||||
response = yield self._render_response(addresses)
|
||||
defer.returnValue(response)
|
||||
|
||||
@AuthJSONRPCServer.auth_required
|
||||
def jsonrpc_get_new_address(self):
|
||||
|
|
|
@ -64,8 +64,7 @@ def main():
|
|||
os.path.basename(sys.argv[0]))
|
||||
)
|
||||
else:
|
||||
help_response = api.call('help', params)
|
||||
print help_response['help'] if 'help' in help_response else help_response
|
||||
print_help_response(api.call('help', params))
|
||||
|
||||
elif method not in api.commands():
|
||||
print_error("'" + method + "' is not a valid command.")
|
||||
|
@ -84,13 +83,16 @@ def main():
|
|||
# instead of this generic message.
|
||||
# https://app.asana.com/0/158602294500137/200173944358192
|
||||
print "Something went wrong, here's the usage for %s:" % method
|
||||
print api.call('help', {'command': method})
|
||||
print_help_response(api.call('help', {'command': method}))
|
||||
if hasattr(err, 'msg'):
|
||||
print "Here's the traceback for the error you encountered:"
|
||||
print err.msg
|
||||
return 1
|
||||
|
||||
|
||||
def print_help_response(help_response):
|
||||
print help_response['help'] if 'help' in help_response else help_response
|
||||
|
||||
def guess_type(x):
|
||||
if '.' in x:
|
||||
try:
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
import argparse
|
||||
import binascii
|
||||
import logging
|
||||
import os
|
||||
import StringIO
|
||||
import sys
|
||||
|
||||
|
@ -11,7 +10,6 @@ from twisted.internet import reactor
|
|||
|
||||
from lbrynet import conf
|
||||
from lbrynet.cryptstream import CryptBlob
|
||||
from lbrynet.core import HashBlob
|
||||
from lbrynet.core import log_support
|
||||
from lbrynet.core import cryptoutils
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ from lbrynet.core import log_support
|
|||
|
||||
import argparse
|
||||
import collections
|
||||
import itertools
|
||||
import logging
|
||||
import os
|
||||
import random
|
||||
|
@ -11,25 +10,15 @@ import shutil
|
|||
import sys
|
||||
import tempfile
|
||||
|
||||
import appdirs
|
||||
from twisted.internet import defer
|
||||
from twisted.internet import reactor
|
||||
from twisted.internet import protocol
|
||||
from twisted.internet import endpoints
|
||||
|
||||
from lbrynet import analytics
|
||||
from lbrynet import conf
|
||||
from lbrynet.core import Error
|
||||
from lbrynet.core import Wallet
|
||||
from lbrynet.core import BlobAvailability
|
||||
from lbrynet.core import HashAnnouncer
|
||||
from lbrynet.core import PeerManager
|
||||
from lbrynet.core import Session
|
||||
from lbrynet.core import utils
|
||||
from lbrynet.core.client import DHTPeerFinder
|
||||
from lbrynet.dht import node
|
||||
from lbrynet.metadata import Metadata
|
||||
from lbrynet.core import StreamDescriptor as sd
|
||||
|
||||
import common
|
||||
import name
|
||||
|
|
Loading…
Reference in a new issue