diff --git a/main.lisp b/main.lisp index fd9866e..9f3750c 100644 --- a/main.lisp +++ b/main.lisp @@ -679,17 +679,41 @@ ("allow-offline" ,allow-offline) ,(if ttl (list "ttl" ttl)))))) -;; STRING → ALIST || (NIL STRING) +;; STRING → STRING || (NIL STRING) (defun name-pubsub-cancel (name) "Cancel subscription to a name. /ipns/docs.ipfs.io/reference/api/http/#api-v0-name-pubsub-cancel" - (bind-api-alist (ipfs-call "name/pubsub/cancel" `(("arg" ,name))))) + (bind-api-result (ipfs-call "name/pubsub/cancel" `(("arg" ,name))) + (gethash "Canceled" result))) -;; NIL → ALIST || (NIL STRING) +;; NIL → STRING || (NIL STRING) (defun name-pubsub-state () "Query the state of IPNS pubsub. /ipns/docs.ipfs.io/reference/api/http/#api-v0-name-pubsub-state" - (bind-api-alist (ipfs-call "name/pubsub/state" '()))) + (bind-api-result (ipfs-call "name/pubsub/state" '()) + (gethash "Enabled" result))) + +;; NIL → STRING || (NIL STRING) +(defun name-pubsub-subs () + "Show current name subscriptions. + /ipns/docs.ipfs.io/reference/api/http/#api-v0-name-pubsub-subs" + (bind-api-result (ipfs-call "name/pubsub/subs" '()) + (gethash "Strings" result))) + +;; STRING [:BOOLEAN :BOOLEAN :NUMBER :STRING] → STRING || (NIL STRING) +(defun name-resolve (name &key (recursive 't) (nocache "") + (dht-record-count nil) (dht-timeout nil)) + "Resolve a given IPNS name. + /ipns/docs.ipfs.io/reference/api/http/#api-v0-name-resolve" + (bind-api-result + (ipfs-call "name/resolve" `(("arg" ,name)("recursive" ,recursive) + ,(when (not (empty-string-p nocache)) + (list "nocache" nocache)) + ,(when dht-record-count + (list "dht-record-count" dht-record-count)) + ,(when dht-timeout + (list "dht-timeout" dht-timeout)))) + (gethash "Path" result))) diff --git a/package.lisp b/package.lisp index 97e2e14..c849314 100644 --- a/package.lisp +++ b/package.lisp @@ -98,6 +98,8 @@ :name-publish :name-pubsub-cancel :name-pubsub-state + :name-pubsub-subs + :name-resolve ;; pubsub calls :pubsub-sub