Browse code

Updated name calls, fixed returns

Jaidyn Levesque authored on 2019-06-18 08:04:19
Showing 2 changed files
... ...
@@ -679,17 +679,41 @@
679 679
 				("allow-offline" ,allow-offline)
680 680
 				,(if ttl (list "ttl" ttl))))))
681 681
 
682
-;; STRING → ALIST || (NIL STRING)
682
+;; STRING → STRING || (NIL STRING)
683 683
 (defun name-pubsub-cancel (name)
684 684
   "Cancel subscription to a name.
685 685
   /ipns/docs.ipfs.io/reference/api/http/#api-v0-name-pubsub-cancel"
686
-  (bind-api-alist (ipfs-call "name/pubsub/cancel" `(("arg" ,name)))))
686
+  (bind-api-result (ipfs-call "name/pubsub/cancel" `(("arg" ,name)))
687
+		   (gethash "Canceled" result)))
687 688
 
688
-;; NIL → ALIST || (NIL STRING)
689
+;; NIL → STRING || (NIL STRING)
689 690
 (defun name-pubsub-state ()
690 691
   "Query the state of IPNS pubsub.
691 692
   /ipns/docs.ipfs.io/reference/api/http/#api-v0-name-pubsub-state"
692
-  (bind-api-alist (ipfs-call "name/pubsub/state" '())))
693
+  (bind-api-result (ipfs-call "name/pubsub/state" '())
694
+		   (gethash "Enabled" result)))
695
+
696
+;; NIL → STRING || (NIL STRING)
697
+(defun name-pubsub-subs ()
698
+  "Show current name subscriptions.
699
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-name-pubsub-subs"
700
+  (bind-api-result (ipfs-call "name/pubsub/subs" '())
701
+		   (gethash "Strings" result)))
702
+
703
+;; STRING [:BOOLEAN :BOOLEAN :NUMBER :STRING] → STRING || (NIL STRING)
704
+(defun name-resolve (name &key (recursive 't) (nocache "")
705
+			  (dht-record-count nil) (dht-timeout nil))
706
+  "Resolve a given IPNS name.
707
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-name-resolve"
708
+  (bind-api-result
709
+    (ipfs-call "name/resolve" `(("arg" ,name)("recursive" ,recursive)
710
+				,(when (not (empty-string-p nocache))
711
+				   (list "nocache" nocache))
712
+				,(when dht-record-count
713
+				   (list "dht-record-count" dht-record-count))
714
+				,(when dht-timeout
715
+				   (list "dht-timeout" dht-timeout))))
716
+    (gethash "Path" result)))
693 717
 
694 718
 
695 719
 
... ...
@@ -98,6 +98,8 @@
98 98
     :name-publish
99 99
     :name-pubsub-cancel
100 100
     :name-pubsub-state
101
+    :name-pubsub-subs
102
+    :name-resolve
101 103
 
102 104
     ;; pubsub calls
103 105
     :pubsub-sub