2018-01-14 22:51:18 +00:00
|
|
|
class Daemon(object):
|
2018-02-15 20:41:51 +00:00
|
|
|
"""Monero daemon.
|
|
|
|
|
|
|
|
Provides interface do a daemon instance.
|
|
|
|
|
|
|
|
:param backend: a daemon backend
|
|
|
|
"""
|
2018-01-14 22:51:18 +00:00
|
|
|
def __init__(self, backend):
|
|
|
|
self._backend = backend
|
|
|
|
|
2018-01-28 15:11:27 +00:00
|
|
|
def info(self):
|
2018-02-15 20:41:51 +00:00
|
|
|
"""
|
|
|
|
Returns basic information about the daemon.
|
|
|
|
|
|
|
|
:rtype: dict
|
|
|
|
"""
|
2018-01-28 15:11:27 +00:00
|
|
|
return self._backend.info()
|
2018-01-15 03:12:53 +00:00
|
|
|
|
2018-01-28 15:11:27 +00:00
|
|
|
def height(self):
|
2018-02-15 20:41:51 +00:00
|
|
|
"""
|
|
|
|
Return daemon's chain height.
|
|
|
|
|
|
|
|
:rtype: int
|
|
|
|
"""
|
2018-01-28 15:11:27 +00:00
|
|
|
return self._backend.info()['height']
|
2018-01-22 02:55:08 +00:00
|
|
|
|
2018-01-30 23:22:26 +00:00
|
|
|
def send_transaction(self, tx, relay=True):
|
2018-02-15 20:41:51 +00:00
|
|
|
"""
|
|
|
|
Sends a transaction generated by a :class:`Wallet <monero.wallet.Wallet>`.
|
|
|
|
|
|
|
|
:param tx: :class:`Transaction <monero.transaction.Transaction>`
|
|
|
|
:param relay: whether to relay the transaction to peers. If `False`, the daemon will have
|
|
|
|
to mine the transaction itself in order to have it included in the blockchain.
|
|
|
|
"""
|
2018-01-30 23:22:26 +00:00
|
|
|
return self._backend.send_transaction(tx.blob, relay=relay)
|
2018-01-22 02:55:08 +00:00
|
|
|
|
2018-01-28 15:11:27 +00:00
|
|
|
def mempool(self):
|
|
|
|
return self._backend.mempool()
|