File tree Expand file tree Collapse file tree 2 files changed +38
-2
lines changed
Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Original file line number Diff line number Diff line change @@ -170,7 +170,30 @@ class Name {
170170 }
171171
172172 class DHT {
173- // TODO findprovs get put
173+ public Map findprovs (MerkleNode node ) throws IOException {
174+ Map res = (Map ) retrieveAndParse ("dht/findprovs?arg=" + node .hash );
175+ return res ;
176+ }
177+
178+ public Map query (NodeAddress addr ) throws IOException {
179+ Map res = (Map ) retrieveAndParse ("dht/query?arg=" + addr .address );
180+ return res ;
181+ }
182+
183+ public Map findpeer (NodeAddress addr ) throws IOException {
184+ Map res = (Map ) retrieveAndParse ("dht/findpeer?arg=" + addr .address );
185+ return res ;
186+ }
187+
188+ public Map get (MerkleNode node ) throws IOException {
189+ Map res = (Map ) retrieveAndParse ("dht/get?arg=" + node .hash );
190+ return res ;
191+ }
192+
193+ public Map put (String key , String value ) throws IOException {
194+ Map res = (Map ) retrieveAndParse ("dht/put?arg=" + key + "&arg=" +value );
195+ return res ;
196+ }
174197 }
175198
176199 class File {
Original file line number Diff line number Diff line change @@ -117,7 +117,20 @@ public void mountTest() {
117117 }
118118 }
119119
120-
120+ @ org .junit .Test
121+ public void dhtTest () {
122+ try {
123+ MerkleNode pointer = new MerkleNode ("QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB" );
124+ Map get = ipfs .dht .get (pointer );
125+ Map put = ipfs .dht .put ("somekey" , "somevalue" );
126+ Map findprovs = ipfs .dht .findprovs (pointer );
127+ List <NodeAddress > peers = ipfs .swarm .peers ();
128+ Map query = ipfs .dht .query (peers .get (0 ));
129+ Map find = ipfs .dht .findpeer (peers .get (0 ));
130+ } catch (IOException e ) {
131+ throw new RuntimeException (e );
132+ }
133+ }
121134
122135 @ org .junit .Test
123136 public void statsTest () {
You can’t perform that action at this time.
0 commit comments