1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the "php-ipfs" package. |
7
|
|
|
* |
8
|
|
|
* (c) Robert Schönthal <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace IPFS\Api; |
15
|
|
|
|
16
|
|
|
use IPFS\Annotation\Api as Endpoint; |
17
|
|
|
use IPFS\Command\Command; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @author Robert Schönthal <[email protected]> |
21
|
|
|
* @autogenerated |
22
|
|
|
* @codeCoverageIgnore |
23
|
|
|
*/ |
24
|
|
|
final class Dht implements Api |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* Query the DHT for all of the multiaddresses associated with a Peer ID. |
28
|
|
|
* |
29
|
|
|
* @Endpoint(name="dht:findpeer") |
30
|
|
|
* |
31
|
|
|
* @param string $arg the ID of the peer to search for |
32
|
|
|
* @param bool $verbose print extra information |
33
|
|
|
* |
34
|
|
|
* @return Command |
35
|
|
|
*/ |
36
|
|
|
public function findpeer(string $arg, bool $verbose = false): Command |
37
|
|
|
{ |
38
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Find peers in the DHT that can provide a specific value, given a key. |
43
|
|
|
* |
44
|
|
|
* @Endpoint(name="dht:findprovs") |
45
|
|
|
* |
46
|
|
|
* @param string $arg the key to find providers for |
47
|
|
|
* @param bool $verbose print extra information |
48
|
|
|
* |
49
|
|
|
* @return Command |
50
|
|
|
*/ |
51
|
|
|
public function findprovs(string $arg, bool $verbose = false): Command |
52
|
|
|
{ |
53
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Given a key, query the DHT for its best value. |
58
|
|
|
* |
59
|
|
|
* @Endpoint(name="dht:get") |
60
|
|
|
* |
61
|
|
|
* @param string $arg the key to find a value for |
62
|
|
|
* @param bool $verbose print extra information |
63
|
|
|
* |
64
|
|
|
* @return Command |
65
|
|
|
*/ |
66
|
|
|
public function get(string $arg, bool $verbose = false): Command |
67
|
|
|
{ |
68
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Announce to the network that you are providing given values. |
73
|
|
|
* |
74
|
|
|
* @Endpoint(name="dht:provide") |
75
|
|
|
* |
76
|
|
|
* @param string $arg the key[s] to send provide records for |
77
|
|
|
* @param bool $verbose print extra information |
78
|
|
|
* @param bool $recursive recursively provide entire graph |
79
|
|
|
* |
80
|
|
|
* @return Command |
81
|
|
|
*/ |
82
|
|
|
public function provide(string $arg, bool $verbose = false, bool $recursive = false): Command |
83
|
|
|
{ |
84
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Write a key/value pair to the DHT. |
89
|
|
|
* |
90
|
|
|
* @Endpoint(name="dht:put") |
91
|
|
|
* |
92
|
|
|
* @param string $arg the key to store the value at |
93
|
|
|
* @param string $arg1 the value to store |
94
|
|
|
* @param bool $verbose print extra information |
95
|
|
|
* |
96
|
|
|
* @return Command |
97
|
|
|
*/ |
98
|
|
|
public function put(string $arg, string $arg1, bool $verbose = false): Command |
99
|
|
|
{ |
100
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Find the closest Peer IDs to a given Peer ID by querying the DHT. |
105
|
|
|
* |
106
|
|
|
* @Endpoint(name="dht:query") |
107
|
|
|
* |
108
|
|
|
* @param string $arg the peerID to run the query against |
109
|
|
|
* @param bool $verbose print extra information |
110
|
|
|
* |
111
|
|
|
* @return Command |
112
|
|
|
*/ |
113
|
|
|
public function query(string $arg, bool $verbose = false): Command |
114
|
|
|
{ |
115
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
116
|
|
|
} |
117
|
|
|
} |
118
|
|
|
|