Browse code

Add swarm calls

Jaidyn Levesque authored on 2019-06-19 16:56:35
Showing 2 changed files
... ...
@@ -1051,6 +1051,75 @@
1051 1051
 
1052 1052
 
1053 1053
 
1054
+;; —————————————————————————————————————
1055
+;; SWARM CALLS
1056
+
1057
+;; NIL → ALIST || (NIL STRING)
1058
+(defun swarm-addrs ()
1059
+  "List known addresses.
1060
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-swarm-addrs"
1061
+  (bind-api-result (ipfs-call "swarm/addrs" '())
1062
+		   (re-hash-table-alist (gethash "Addrs" result))))
1063
+
1064
+;; NIL → LIST || (NIL STRING)
1065
+(defun swarm-addrs-listen ()
1066
+  "List interface listening addresses.
1067
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-swarm-addrs-listen"
1068
+  (bind-api-result (ipfs-call "swarm/addrs/listen" '())
1069
+		   (gethash "Strings" result)))
1070
+
1071
+;; NIL → LIST || (NIL STRING)
1072
+(defun swarm-addrs-local ()
1073
+  "List local addresses.
1074
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-swarm-addrs-local"
1075
+  (bind-api-result (ipfs-call "swarm/addrs/local" '())
1076
+		   (gethash "Strings" result)))
1077
+
1078
+;; STRING → LIST || (NIL STRING)
1079
+(defun swarm-connect (address)
1080
+  "Open connection to a given address.
1081
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-swarm-connect"
1082
+  (bind-api-result (ipfs-call "swarm/connect" `(("arg" ,address)))
1083
+		   (gethash "Strings" result)))
1084
+
1085
+;; STRING → LIST || (NIL STRING)
1086
+(defun swarm-disconnect (address)
1087
+  "Close connection to a given address.
1088
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-swarm-disconnect"
1089
+  (bind-api-result (ipfs-call "swarm/disconnect" `(("arg" ,address)))
1090
+		   (gethash "Strings" result)))
1091
+
1092
+
1093
+;; NIL → LIST || (NIL STRING)
1094
+(defun swarm-filters ()
1095
+  "List address filters.
1096
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-swarm-filters"
1097
+  (bind-api-result (ipfs-call "swarm/filters" '()) (gethash "Strings" result)))
1098
+
1099
+;; STRING → LIST || (NIL STRING)
1100
+(defun swarm-filters-add (multiaddr)
1101
+  "Add an address filter.
1102
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-swarm-filters-add"
1103
+  (bind-api-result (ipfs-call "swarm/filters/add" `(("arg" ,multiaddr)))
1104
+		   (gethash "Strings" result)))
1105
+
1106
+;; STRING → LIST || (NIL STRING)
1107
+(defun swarm-filters-rm (multiaddr)
1108
+  "Remove an address filter.
1109
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-swarm-filters-rm"
1110
+  (bind-api-result (ipfs-call "swarm/filters/rm" `(("arg" ,multiaddr)))
1111
+		   (gethash "Strings" result)))
1112
+
1113
+;; NIL → ALIST || (NIL STRING)
1114
+(defun swarm-peers ()
1115
+  "List peers with open connections.
1116
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-swarm-peers"
1117
+  (bind-api-result (ipfs-call "swarm/peers" '())
1118
+		   (mapcar #'re-hash-table-alist (gethash "Peers" result))))
1119
+
1120
+
1121
+
1122
+
1054 1123
 ;; —————————————————————————————————————
1055 1124
 ;; VERSION CALLS
1056 1125
 
... ...
@@ -152,6 +152,17 @@
152 152
     :stats-bw
153 153
     :stats-repo
154 154
 
155
+    ;; swarm calls
156
+    :swarm-addrs
157
+    :swarm-addrs-listen
158
+    :swarm-addrs-local
159
+    :swarm-connect
160
+    :swarm-disconnect
161
+    :swarm-filters
162
+    :swarm-filters-add
163
+    :swarm-filters-rm
164
+    :swarm-peers
165
+
155 166
     ;; version calls
156 167
     :version
157 168
     :version-deps))