From af99edc764102116f2fd9ee22bef54560699880f Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Wed, 27 Sep 2017 17:30:22 -0400 Subject: [PATCH] add get_host_downloaded_from --- lbrynet/core/BlobManager.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lbrynet/core/BlobManager.py b/lbrynet/core/BlobManager.py index f6c329dc1..6293db4ff 100644 --- a/lbrynet/core/BlobManager.py +++ b/lbrynet/core/BlobManager.py @@ -128,6 +128,16 @@ class DiskBlobManager(DHTHashSupplier): d = self._add_blob_to_download_history(blob_hash, host, rate) return d + @defer.inlineCallbacks + def get_host_downloaded_from(self, blob_hash): + query_str = "SELECT host FROM download WHERE blob=? ORDER BY ts DESC LIMIT 1" + host = yield self.db_conn.runQuery(query_str, (blob_hash,)) + if host: + result = host[0][0] + else: + result = None + defer.returnValue(result) + def add_blob_to_upload_history(self, blob_hash, host, rate): d = self._add_blob_to_upload_history(blob_hash, host, rate) return d