Skip to content

Commit

Permalink
feat(linksystem): add option to disable hash on read
Browse files Browse the repository at this point in the history
Have boolean that specifies whether the storage is trusted. if it is, skip hashing on reads
  • Loading branch information
hannahhoward committed Mar 5, 2021
1 parent 8fef531 commit df2f100
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions linking.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions linksystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit df2f100

Please sign in to comment.