diff options
Diffstat (limited to 'src/eris-decode.lisp')
-rw-r--r-- | src/eris-decode.lisp | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/src/eris-decode.lisp b/src/eris-decode.lisp index df64913..ac458fb 100644 --- a/src/eris-decode.lisp +++ b/src/eris-decode.lisp @@ -209,7 +209,7 @@ it is necessary and sets the position in the buffer to 0." -(defun eris-decode (read-capability fetch-function &key (cache-capacity 2048)) +(defun eris-decode (read-capability fetch-function) "Using the FETCH-FUNCTION, return a stream that decodes the READ-CAPABILITY. This stream implements the Gray streams protocol. @@ -219,32 +219,18 @@ be destructively modified, so you MUST provide a fresh array every time. If a hash-table is used, a (copy-seq) needs to be done on the return value of gethash. -The keyword argument CACHE-CAPACITY indicates the amount of blocks stored in the -cache. It may be NIL to turn off caching entirely. - The conditions ERIS:MISSING-BLOCK, ERIS:PADDING, ERIS:HASH-MISMATCH and ERIS:EOF may be signaled by operations on the stream. Any condition signaled from within FETCH-FUNCTION is not handled." (declare (type read-capability read-capability) - (type function fetch-function) - (type (or integer null) cache-capacity)) + (type function fetch-function)) (with-slots (level block-size root-reference-pair) read-capability - (let* ((get-block (if cache-capacity ;; handle caching - (cached-lambda (:cache-class 'lru-cache - :capacity cache-capacity - :table (make-hash-table :size (1+ cache-capacity) :test #'equalp)) - (rk nonce) - (declare (type octet-vector rk nonce)) - (let ((block (execute-fetch-function fetch-function rk))) - (declare (type octet-vector block)) - (hash-check block rk) - (decrypt-block block rk nonce))) - (lambda (rk nonce) - (declare (type octet-vector rk nonce)) - (let ((block (execute-fetch-function fetch-function rk))) - (declare (type octet-vector block)) - (hash-check block rk) - (decrypt-block block rk nonce))))) + (let* ((get-block (lambda (rk nonce) + (declare (type octet-vector rk nonce)) + (let ((block (execute-fetch-function fetch-function rk))) + (declare (type octet-vector block)) + (hash-check block rk) + (decrypt-block block rk nonce)))) (root (funcall get-block root-reference-pair (make-nonce level)))) ;; "Implementations MUST verify the key appearing in the read capability ;; if level of encoded content is larger than 0." |