Skip to content

Commit

Permalink
no api yet
Browse files Browse the repository at this point in the history
  • Loading branch information
shyba committed Oct 25, 2021
1 parent 8a82961 commit 17316b7
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 95 deletions.
53 changes: 0 additions & 53 deletions lbry/extras/daemon/daemon.py
Expand Up @@ -3030,59 +3030,6 @@ async def jsonrpc_channel_export(self, channel_id=None, channel_name=None, accou
}
return base58.b58encode(json.dumps(export, separators=(',', ':')))

@requires(WALLET_COMPONENT)
def jsonrpc_channel_subscription_list(self):
"""
List subscribed channels and modes.
Usage:
channel_subscription_list
Returns:
(list) [(channel_id, download_latest, download_all)]
"""
return self.storage.get_subscriptions()

@requires(WALLET_COMPONENT)
def jsonrpc_channel_subscribe(self, channel_id, download_latest=None, download_all=False):
"""
Subscribe to a channel and optionally start downloading streams proactively.
Usage:
channel_subscribe (<channel_id> | --channel_id=<channel_id>) [--download_latest=<download_latest>]
[--download_all]
Options:
--channel_id=<channel_id> : (str) claim id of channel to subscribe.
--download_latest=<download_latest> : (int) amount of newest streams to ensure download.
--download_all : (bool) download all streams from the channel.
Returns:
(bool) Subscription successful? (False only if channel doesn't exist)
"""
if download_all and download_latest is not None:
raise ConflictingInputValueError("download_latest", "download_all")
return self.storage.add_subscription(channel_id, download_latest, download_all)

@requires(WALLET_COMPONENT)
def jsonrpc_channel_unsubscribe(self, channel_id):
"""
Subscribe to a channel and optionally start downloading streams proactively.
Usage:
channel_subscribe (<channel_id> | --channel_id=<channel_id>) [--download=<download>]
Options:
--channel_id=<channel_id> : (str) claim id of channel to subscribe
--download=<download> : (str) which strategy to use for downloads: 'all' for everything.
'latest-X' for the latest X streams. None (default) for nothing.
Returns:
(bool) Subscription successful? (False only if channel doesn't exist)
"""
return self.storage.remove_subscription(channel_id)


@requires(WALLET_COMPONENT)
async def jsonrpc_channel_import(self, channel_data, wallet_id=None):
"""
Expand Down
19 changes: 0 additions & 19 deletions lbry/extras/daemon/storage.py
Expand Up @@ -235,12 +235,6 @@ class SQLiteStorage(SQLiteMixin):
pragma foreign_keys=on;
pragma journal_mode=WAL;
create table if not exists subscription (
channel_id char(40) primary key not null,
download_latest integer not null default 0,
download_all integer not null default 0
);
create table if not exists blob (
blob_hash char(96) primary key not null,
blob_length integer not null,
Expand Down Expand Up @@ -545,19 +539,6 @@ def delete_stream(self, descriptor: 'StreamDescriptor'):
async def delete_torrent(self, bt_infohash: str):
return await self.db.run(delete_torrent, bt_infohash)

# # # # # # # # # subscriptions # # # # # # # # #

def add_subscription(self, channel_id, download_latest=None, download_all=None):
return self.db.execute_fetchall(
"insert or replace into subscription(channel_id, download_latest, download_all) values (?, ?, ?)",
(channel_id, download_latest or 0, 1 if download_all else 0))

def remove_subscription(self, channel_id):
return self.db.execute_fetchall("delete from subscription where channel_id=?", (channel_id,))

def get_subscriptions(self):
return self.db.execute_fetchall("select channel_id, download_latest, download_all from subscription")

# # # # # # # # # file stuff # # # # # # # # #

def save_downloaded_file(self, stream_hash: str, file_name: typing.Optional[str],
Expand Down
4 changes: 0 additions & 4 deletions lbry/stream/managed_stream.py
Expand Up @@ -246,10 +246,6 @@ def _write_decrypted_blob(output_path: str, data: bytes):
handle.write(data)
handle.flush()

async def save_blobs(self):
async for _ in self._aiter_read_stream(0, connection_id=self.STREAMING_ID):
pass

async def _save_file(self, output_path: str):
log.info("save file for lbry://%s#%s (sd hash %s...) -> %s", self.claim_name, self.claim_id, self.sd_hash[:6],
output_path)
Expand Down
19 changes: 0 additions & 19 deletions tests/integration/datanetwork/test_file_commands.py
Expand Up @@ -616,22 +616,3 @@ async def test_ensure_download(self):
self.assertEqual(0, len(await self.file_list()))
await self.daemon.blob_manager.delete_blobs(list(self.daemon.blob_manager.completed_blob_hashes), True)
self.assertEqual(0, len((await self.daemon.jsonrpc_blob_list())['items']))

await proactive_downloader.stop()
await self.daemon.jsonrpc_channel_subscribe(channel_id, 1)
await proactive_downloader.start()
await proactive_downloader.finished_iteration.wait()
await self.assertBlobs(content1)
await self.daemon.jsonrpc_file_delete(delete_all=True)

await self.daemon.jsonrpc_channel_subscribe(channel_id, download_all=True)
await proactive_downloader.stop()
await proactive_downloader.start()
await proactive_downloader.finished_iteration.wait()
await self.assertBlobs(content1, content2)

self.assertEqual(0, len(await self.file_list()))

self.assertEqual([(channel_id, 0, 1)], await self.daemon.jsonrpc_channel_subscription_list())
await self.daemon.jsonrpc_channel_unsubscribe(channel_id)
self.assertEqual([], await self.daemon.jsonrpc_channel_subscription_list())

0 comments on commit 17316b7

Please sign in to comment.