popcorn-official / popcorn-android

Popcorn Time is a multi-platform, free software BitTorrent client that includes an integrated media player ( Android / AndroidTV ) A Butter-Project Fork
https://popcorn-time.site
Other
1.26k stars 278 forks source link

dht - load servers #806

Closed ivan1986 closed 2 years ago

ivan1986 commented 2 years ago

@julyworlds need help Can you look what i do wrong.

I try to load data from dht for update server endpoints same code work in desktop version - https://github.com/popcorn-official/popcorn-desktop/blob/development/src/app/dht.js#L26= but here i get "\<uninitialized>"

julyworlds commented 2 years ago

Im not sure what is going on, but according to the library you use .get to get values stored using .put before.

dht.get(hash, opts, callback)

Read a data record (created with .put()) from the DHT. ([BEP 44](http://bittorrent.org/beps/bep_0044.html))

Given hash, a hex string or buffer, lookup data content from the DHT, sending the result in callback(err, res).

Also apparently you need to do a put every 2 hours so it does not dissapear.

Note that you should call .put() every hour for content that you want to keep alive, since nodes may discard data nodes older than 2 hours.
ivan1986 commented 2 years ago

i use put here https://github.com/popcorn-time-ru/dht-annoncer/blob/master/put.js but yes, need test store and test load with all libs (java and node)

i annonce mutable dht json, where i store actual endpoints in case we lost dns names, which was some times

julyworlds commented 2 years ago

In theory you need to use the exact hash generated by the .put in the .get I dont see that hash being stored and used in the .get.

ivan1986 commented 2 years ago

it's a4a9ad29e303e137ecb995c50a4e104b3e8f72e5 - hash generated on server by private/public keys and uses on desktop client i try store item by java and correct read it in java and in node, but now try only immutable try mutable now

ivan1986 commented 2 years ago

oh, i'm sorry, all works, public key

ivan1986 commented 2 years ago

@julyworlds done, it works can you look, maybe i use bad solutions and it's make simple in dht store json with server field - it's separated endpoints - use it's in random order

julyworlds commented 2 years ago

Looks good 👍