forked from LBRYCommunity/lbry-sdk
add auto_renew_claim_height_delta to configuration and auto renew after startup if necessary
This commit is contained in:
parent
1ea8c1ad29
commit
e4e60ebe9b
2 changed files with 24 additions and 0 deletions
|
@ -242,6 +242,10 @@ ADJUSTABLE_SETTINGS = {
|
||||||
# all of your credits.
|
# all of your credits.
|
||||||
'api_host': (str, 'localhost'),
|
'api_host': (str, 'localhost'),
|
||||||
'api_port': (int, 5279),
|
'api_port': (int, 5279),
|
||||||
|
# claims set to expire within this many blocks will be
|
||||||
|
# automatically renewed after startup (if set to 0, renews
|
||||||
|
# will not be made automatically)
|
||||||
|
'auto_renew_claim_height_delta': (int, 0),
|
||||||
'cache_time': (int, 150),
|
'cache_time': (int, 150),
|
||||||
'data_dir': (str, default_data_dir),
|
'data_dir': (str, default_data_dir),
|
||||||
'data_rate': (float, .0001), # points/megabyte
|
'data_rate': (float, .0001), # points/megabyte
|
||||||
|
|
|
@ -188,6 +188,8 @@ class Daemon(AuthJSONRPCServer):
|
||||||
self.reflector_port = conf.settings['reflector_port']
|
self.reflector_port = conf.settings['reflector_port']
|
||||||
self.dht_node_port = conf.settings['dht_node_port']
|
self.dht_node_port = conf.settings['dht_node_port']
|
||||||
self.use_upnp = conf.settings['use_upnp']
|
self.use_upnp = conf.settings['use_upnp']
|
||||||
|
self.auto_renew_claim_height_delta = conf.settings['auto_renew_claim_height_delta']
|
||||||
|
|
||||||
|
|
||||||
self.startup_status = STARTUP_STAGES[0]
|
self.startup_status = STARTUP_STAGES[0]
|
||||||
self.connected_to_internet = True
|
self.connected_to_internet = True
|
||||||
|
@ -255,6 +257,7 @@ class Daemon(AuthJSONRPCServer):
|
||||||
yield self._setup_server()
|
yield self._setup_server()
|
||||||
log.info("Starting balance: " + str(self.session.wallet.get_balance()))
|
log.info("Starting balance: " + str(self.session.wallet.get_balance()))
|
||||||
yield _announce_startup()
|
yield _announce_startup()
|
||||||
|
self._auto_renew()
|
||||||
|
|
||||||
def _get_platform(self):
|
def _get_platform(self):
|
||||||
if self.platform is None:
|
if self.platform is None:
|
||||||
|
@ -290,6 +293,23 @@ class Daemon(AuthJSONRPCServer):
|
||||||
if not self.connected_to_internet:
|
if not self.connected_to_internet:
|
||||||
self.connection_status_code = CONNECTION_STATUS_NETWORK
|
self.connection_status_code = CONNECTION_STATUS_NETWORK
|
||||||
|
|
||||||
|
@defer.inlineCallbacks
|
||||||
|
def _auto_renew(self):
|
||||||
|
# automatically renew claims
|
||||||
|
# auto renew is turned off if 0 or some negative number
|
||||||
|
if self.auto_renew_claim_height_delta < 1:
|
||||||
|
return
|
||||||
|
log.debug("Renewing claim")
|
||||||
|
h = self.session.wallet.network.get_local_height() + self.auto_renew_claim_height_delta
|
||||||
|
results = yield self.session.wallet.claim_renew_all_before_expiration(h)
|
||||||
|
for outpoint, result in results.iteritems():
|
||||||
|
if result['success']:
|
||||||
|
log.info("Renewed claim at outpoint:%s claim ID:%s, paid fee:%s",
|
||||||
|
outpoint, result['claim_id'], result['fee'])
|
||||||
|
else:
|
||||||
|
log.info("Failed to renew claim at outpoint:%s, reason:%s",
|
||||||
|
outpoint, result['reason'])
|
||||||
|
|
||||||
def _start_server(self):
|
def _start_server(self):
|
||||||
if self.peer_port is not None:
|
if self.peer_port is not None:
|
||||||
server_factory = ServerProtocolFactory(self.session.rate_limiter,
|
server_factory = ServerProtocolFactory(self.session.rate_limiter,
|
||||||
|
|
Loading…
Add table
Reference in a new issue