From 47be6a3f8c3788aef7d18d4904e74f291c6d9492 Mon Sep 17 00:00:00 2001 From: Jaidyn Levesque Date: Tue, 18 Jun 2019 12:18:08 -0500 Subject: [PATCH] Add pin calls --- main.lisp | 41 +++++++++++++++++++++++++++++++++++++++++ package.lisp | 7 +++++++ 2 files changed, 48 insertions(+) diff --git a/main.lisp b/main.lisp index 7fde225..1535464 100644 --- a/main.lisp +++ b/main.lisp @@ -851,6 +851,47 @@ +;; ————————————————————————————————————— +;; PIN CALLS + +;; STRING [:BOOLEAN] → ALIST || (NIL STRING) +(defun pin-add (path &key (recursive 'T)) + "Pin an object to local storage. + /ipns/docs.ipfs.io/reference/api/http/#api-v0-pin-add" + (bind-api-alist + (ipfs-call "pin/add" `(("arg" ,path)("recursive" ,recursive))))) + +;; [:STRING :STRING] → ALIST || (NIL STRING) +(defun pin-ls (&key (path nil) (type "all")) + "List objects pinned to local storage. + /ipns/docs.ipfs.io/reference/api/http/#api-v0-pin-ls" + (bind-api-alist + (ipfs-call "pin/ls" `(,(when path `("arg" ,path)) ("type" ,type))))) + +;; STRING [:BOOLEAN] → ALIAS || (NIL STRING) +(defun pin-rm (path &key (recursive 'T)) + "Remove pinned objects from local storage. + /ipns/docs.ipfs.io/reference/api/http/#api-v0-pin-rm" + (bind-api-alist + (ipfs-call "pin/rm" `(("arg" ,path)("recursive" ,recursive))))) + +;; STRING STRING [:BOOLEAN] → ALIST || (NIL STRING) +(defun pin-update (old-path new-path &key (unpin 'T)) + "Update a recursive pin. + /ipns/docs.ipfs.io/reference/api/http/#api-v0-pin-update" + (bind-api-alist + (ipfs-call "pin/update" + `(("arg" ,old-path)("arg" ,new-path)("unpin" ,unpin))))) + +;; NIL → ALIST || (NIL STRING) +(defun pin-verify () + "Verify that recursive pins are complete. + /ipns/docs.ipfs.io/reference/api/http/#api-v0-pin-verify" + (bind-api-alist (ipfs-call "pin/verify" '()))) + + + + ;; ————————————————————————————————————— ;; PUBSUB CALLS diff --git a/package.lisp b/package.lisp index 6234bba..97f1545 100644 --- a/package.lisp +++ b/package.lisp @@ -119,6 +119,13 @@ :p2p-stream-close :p2p-stream-ls + ;; pin calls + :pin-add + :pin-ls + :pin-rm + :pin-update + :pin-verify + ;; pubsub calls :pubsub-sub :pubsub-sub-process