2020-05-01 15:33:58 +02:00
|
|
|
import logging
|
2020-10-20 22:48:45 +02:00
|
|
|
from typing import List, Dict, Tuple
|
2020-05-01 15:33:58 +02:00
|
|
|
|
2020-06-05 06:35:22 +02:00
|
|
|
from lbry.blockchain import Ledger, Transaction
|
2020-05-01 15:33:58 +02:00
|
|
|
from lbry.wallet.sync import SPVSync
|
|
|
|
|
|
|
|
from .base import Service
|
2020-05-21 00:05:13 +02:00
|
|
|
from .api import Client
|
2020-05-01 15:33:58 +02:00
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
class LightClient(Service):
|
|
|
|
|
2020-09-17 01:50:51 +02:00
|
|
|
name = "client"
|
|
|
|
|
2020-09-11 20:08:06 +02:00
|
|
|
sync: SPVSync
|
|
|
|
|
2020-06-05 06:35:22 +02:00
|
|
|
def __init__(self, ledger: Ledger):
|
|
|
|
super().__init__(ledger)
|
2020-09-16 16:37:49 +02:00
|
|
|
self.client = Client(
|
|
|
|
f"http://{ledger.conf.full_nodes[0][0]}:{ledger.conf.full_nodes[0][1]}/api"
|
|
|
|
)
|
2020-05-01 15:33:58 +02:00
|
|
|
self.sync = SPVSync(self)
|
|
|
|
|
|
|
|
async def search_transactions(self, txids):
|
|
|
|
return await self.client.transaction_search(txids=txids)
|
|
|
|
|
|
|
|
async def get_block_address_filters(self):
|
|
|
|
return await self.client.address_block_filters()
|
|
|
|
|
|
|
|
async def get_transaction_address_filters(self, block_hash):
|
|
|
|
return await self.client.address_transaction_filters(block_hash=block_hash)
|
2020-06-05 06:35:22 +02:00
|
|
|
|
|
|
|
async def broadcast(self, tx):
|
|
|
|
pass
|
|
|
|
|
|
|
|
async def wait(self, tx: Transaction, height=-1, timeout=1):
|
|
|
|
pass
|
|
|
|
|
2020-07-13 21:45:21 +02:00
|
|
|
async def resolve(self, urls, **kwargs):
|
2020-06-05 06:35:22 +02:00
|
|
|
pass
|
|
|
|
|
|
|
|
async def search_claims(self, accounts, **kwargs):
|
|
|
|
pass
|
2020-08-13 18:08:35 +02:00
|
|
|
|
|
|
|
async def search_supports(self, accounts, **kwargs):
|
|
|
|
pass
|
2020-10-13 20:34:19 +02:00
|
|
|
|
2020-10-16 20:14:38 +02:00
|
|
|
async def sum_supports(self, claim_hash: bytes, include_channel_content=False, exclude_own_supports=False) \
|
2020-10-20 22:48:45 +02:00
|
|
|
-> Tuple[List[Dict], int]:
|
2020-10-16 20:14:38 +02:00
|
|
|
return await self.client.sum_supports(claim_hash, include_channel_content, exclude_own_supports)
|