From df2f1001eeabefe80127e004e30b9790c11ece69 Mon Sep 17 00:00:00 2001 From: hannahhoward Date: Thu, 4 Mar 2021 18:32:00 -0800 Subject: [PATCH] feat(linksystem): add option to disable hash on read Have boolean that specifies whether the storage is trusted. if it is, skip hashing on reads --- linking.go | 3 +++ linksystem.go | 1 + 2 files changed, 4 insertions(+) diff --git a/linking.go b/linking.go index 07200fe1..823d5e21 100644 --- a/linking.go +++ b/linking.go @@ -56,6 +56,9 @@ func (lsys *LinkSystem) Fill(lnkCtx LinkContext, lnk Link, na NodeAssembler) err if err != nil { return err } + if lsys.TrustedStorage { + return decoder(na, reader) + } tee := io.TeeReader(reader, hasher) decodeErr := decoder(na, tee) if decodeErr != nil { // It is important to security to check the hash before returning any other observation about the content. diff --git a/linksystem.go b/linksystem.go index 88942198..299b8d34 100644 --- a/linksystem.go +++ b/linksystem.go @@ -32,6 +32,7 @@ type LinkSystem struct { HasherChooser func(LinkPrototype) (hash.Hash, error) StorageWriteOpener BlockWriteOpener StorageReadOpener BlockReadOpener + TrustedStorage bool } // The following two types define the two directions of transform that a codec can be expected to perform: