2019-01-22 23:45:13 +01:00
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import asyncio
|
2019-06-21 03:02:58 +02:00
|
|
|
from lbry.blob.blob_manager import BlobManager
|
|
|
|
from lbry.blob_exchange.server import BlobServer
|
|
|
|
from lbry.schema.address import decode_address
|
|
|
|
from lbry.extras.daemon.storage import SQLiteStorage
|
2019-01-22 23:45:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
async def main(address: str):
|
|
|
|
try:
|
|
|
|
decode_address(address)
|
|
|
|
except:
|
|
|
|
print(f"'{address}' is not a valid lbrycrd address")
|
|
|
|
return 1
|
|
|
|
loop = asyncio.get_running_loop()
|
|
|
|
|
|
|
|
storage = SQLiteStorage(os.path.expanduser("~/.lbrynet/lbrynet.sqlite"))
|
|
|
|
await storage.open()
|
2019-03-28 19:51:55 +01:00
|
|
|
blob_manager = BlobManager(loop, os.path.expanduser("~/.lbrynet/blobfiles"), storage)
|
2019-01-22 23:45:13 +01:00
|
|
|
await blob_manager.setup()
|
|
|
|
|
|
|
|
server = await loop.create_server(
|
|
|
|
lambda: BlobServer(loop, blob_manager, address),
|
|
|
|
'0.0.0.0', 4444)
|
|
|
|
try:
|
|
|
|
async with server:
|
|
|
|
await server.serve_forever()
|
|
|
|
finally:
|
|
|
|
await storage.close()
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
asyncio.run(main(sys.argv[1]))
|