Add dag calls.

This commit is contained in:
Jaidyn Levesque 2019-06-06 19:59:22 -05:00
parent 48cbdcbdb8
commit fc9a5dd3ba
2 changed files with 35 additions and 0 deletions

View File

@ -364,6 +364,36 @@
;; —————————————————————————————————————
;; DAG CALLS
;; STRING → STRING || (NIL STRING)
(defun dag-get (dag-node)
"Get a dag node from IPFS.
/ipns/docs.ipfs.io/reference/api/http/#api-v0-dag-get"
(bind-api-result
(ipfs-call "dag/get" `(("arg" ,dag-node)))
result))
;; STRING [:STRING :STRING :BOOLEAN] → STRING || (NIL STRING
(defun dag-put (dag-node &key (format "cbor") (input-enc "json") (pin 'T))
"Add a dag node to IPFS. Returns CID string.
/ipns/docs.ipfs.io/reference/api/http/#api-v0-dag-put"
(bind-api-result
(ipfs-call "dag/put" `(("arg" ,dag-node) ("format" ,format)
("input-enc" ,input-enc) ("pin" ,pin)))
(gethash "/" (gethash "Cid" result))))
;; STRING → ALIST || (NIL STRING)
(defun dag-resolve (path)
"Resolve an IPLD block.
/ipns/docs.ipfs.io/reference/api/http/#api-v0-dag-resolve"
(bind-api-alist
(ipfs-call "dag/resolve" `(("arg" ,path)))
result))
;; —————————————————————————————————————
;; VERSION CALLS

View File

@ -43,6 +43,11 @@
:config
:config-show
;; dag calls
:dag-get
:dag-put
:dag-resolve
;; version calls
:version
:version-deps))