X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=README.txt;h=73c365dd18668beab45de491a2da9c78aefe4d47;hb=e0d99ef1d31cef0cf5aec945030bb348ad1ab3d7;hp=7e6135b9db810702eac1d06f0a941a39ab12798a;hpb=41cfe7f09996572946ddcecf950fb8aeaf6e6a46;p=quix0rs-apt-p2p.git diff --git a/README.txt b/README.txt index 7e6135b..73c365d 100644 --- a/README.txt +++ b/README.txt @@ -1,9 +1,16 @@ quick example: -import khashmir, thread -k = khashmir.Khashmir('127.0.0.1', 4444) -thread.start_new_thread(k.dispatcher.run, ()) -k.addContact('127.0.0.1', 8080) # right now we don't do gethostbyname +>>> import khashmir +>>> k = khashmir.test_one(4444) # choose any port +If you want to make another peer in the same session, use peer = khashmir.Khashmir(host, port) then do peer.app.run() to register with the already running thread. + + +>>> k.addContact('127.0.0.1', 8080) # locate another peer +>>> k.findCloseNodes() # query the network to bootstrap our table + +Keys are always 20-character strings (sha1 hashes) + +>>> k.storeKeyForValue(key, value) # no callback right now +>>> k.valueForKey(key, callback) -alternatively, you can call k.dispatcher.runOnce() periodically from whatever thread you choose \ No newline at end of file