summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaidyn Levesque <jadedctrl@teknik.io>2019-06-19 16:56:35 +0000
committerJaidyn Levesque <jadedctrl@teknik.io>2019-06-19 16:56:35 +0000
commitb379b3ef4a7ea45db8cb2b8ce1b1d4a049316e80 (patch)
tree5990b4ca42a4c0ad9143049f19bd28cf62fbb9ad
parentc2b24232a220dae64feb64220fbe6ad570e3d7bb (diff)
downloadcl-ipfs-api2-b379b3ef4a7ea45db8cb2b8ce1b1d4a049316e80.tar.bz2
cl-ipfs-api2-b379b3ef4a7ea45db8cb2b8ce1b1d4a049316e80.zip
Add swarm calls
-rw-r--r--main.lisp69
-rw-r--r--package.lisp11
2 files changed, 80 insertions, 0 deletions
diff --git a/main.lisp b/main.lisp
index 4204237..ccec4a2 100644
--- a/main.lisp
+++ b/main.lisp
@@ -1052,6 +1052,75 @@
;; —————————————————————————————————————
+;; SWARM CALLS
+
+;; NIL → ALIST || (NIL STRING)
+(defun swarm-addrs ()
+ "List known addresses.
+ /ipns/docs.ipfs.io/reference/api/http/#api-v0-swarm-addrs"
+ (bind-api-result (ipfs-call "swarm/addrs" '())
+ (re-hash-table-alist (gethash "Addrs" result))))
+
+;; NIL → LIST || (NIL STRING)
+(defun swarm-addrs-listen ()
+ "List interface listening addresses.
+ /ipns/docs.ipfs.io/reference/api/http/#api-v0-swarm-addrs-listen"
+ (bind-api-result (ipfs-call "swarm/addrs/listen" '())
+ (gethash "Strings" result)))
+
+;; NIL → LIST || (NIL STRING)
+(defun swarm-addrs-local ()
+ "List local addresses.
+ /ipns/docs.ipfs.io/reference/api/http/#api-v0-swarm-addrs-local"
+ (bind-api-result (ipfs-call "swarm/addrs/local" '())
+ (gethash "Strings" result)))
+
+;; STRING → LIST || (NIL STRING)
+(defun swarm-connect (address)
+ "Open connection to a given address.
+ /ipns/docs.ipfs.io/reference/api/http/#api-v0-swarm-connect"
+ (bind-api-result (ipfs-call "swarm/connect" `(("arg" ,address)))
+ (gethash "Strings" result)))
+
+;; STRING → LIST || (NIL STRING)
+(defun swarm-disconnect (address)
+ "Close connection to a given address.
+ /ipns/docs.ipfs.io/reference/api/http/#api-v0-swarm-disconnect"
+ (bind-api-result (ipfs-call "swarm/disconnect" `(("arg" ,address)))
+ (gethash "Strings" result)))
+
+
+;; NIL → LIST || (NIL STRING)
+(defun swarm-filters ()
+ "List address filters.
+ /ipns/docs.ipfs.io/reference/api/http/#api-v0-swarm-filters"
+ (bind-api-result (ipfs-call "swarm/filters" '()) (gethash "Strings" result)))
+
+;; STRING → LIST || (NIL STRING)
+(defun swarm-filters-add (multiaddr)
+ "Add an address filter.
+ /ipns/docs.ipfs.io/reference/api/http/#api-v0-swarm-filters-add"
+ (bind-api-result (ipfs-call "swarm/filters/add" `(("arg" ,multiaddr)))
+ (gethash "Strings" result)))
+
+;; STRING → LIST || (NIL STRING)
+(defun swarm-filters-rm (multiaddr)
+ "Remove an address filter.
+ /ipns/docs.ipfs.io/reference/api/http/#api-v0-swarm-filters-rm"
+ (bind-api-result (ipfs-call "swarm/filters/rm" `(("arg" ,multiaddr)))
+ (gethash "Strings" result)))
+
+;; NIL → ALIST || (NIL STRING)
+(defun swarm-peers ()
+ "List peers with open connections.
+ /ipns/docs.ipfs.io/reference/api/http/#api-v0-swarm-peers"
+ (bind-api-result (ipfs-call "swarm/peers" '())
+ (mapcar #'re-hash-table-alist (gethash "Peers" result))))
+
+
+
+
+;; —————————————————————————————————————
;; VERSION CALLS
;; NIL → STRING
diff --git a/package.lisp b/package.lisp
index c1de9f9..8f3f183 100644
--- a/package.lisp
+++ b/package.lisp
@@ -152,6 +152,17 @@
:stats-bw
:stats-repo
+ ;; swarm calls
+ :swarm-addrs
+ :swarm-addrs-listen
+ :swarm-addrs-local
+ :swarm-connect
+ :swarm-disconnect
+ :swarm-filters
+ :swarm-filters-add
+ :swarm-filters-rm
+ :swarm-peers
+
;; version calls
:version
:version-deps))