Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

Commit

Permalink
swarm/hash: Custom multihash implementation (#633)
Browse files Browse the repository at this point in the history
* swarm/hash: Custom multihash implementation

* swarm/hash, swarm/storage: Delint and fix comments

* swarm/storage: Rebase cleanup

* swarm/multihash: Rename package to multihash

* swarm/multihash, swarm/storage: Remove redundant error formatting

* swarm/multihash: Add missing files

* swarm/storage: Fix error string bug

* swarm/api: Remove sprintf in error
  • Loading branch information
nolash authored Jun 9, 2018
1 parent 2d9dbed commit 3acc595
Show file tree
Hide file tree
Showing 13 changed files with 157 additions and 856 deletions.
11 changes: 3 additions & 8 deletions swarm/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,19 +365,14 @@ func (self *Api) Get(manifestAddr storage.Address, path string) (reader storage.
}

// validate that data as multihash
decodedMultihash, err := multihash.Decode(rsrcData)
decodedMultihash, err := multihash.FromMultihash(rsrcData)
if err != nil {
apiGetInvalid.Inc(1)
status = http.StatusInternalServerError
log.Warn(fmt.Sprintf("could not decode resource multihash: %v", err))
return reader, mimeType, status, nil, err
} else if decodedMultihash.Code != multihash.KECCAK_256 {
apiGetInvalid.Inc(1)
status = http.StatusUnprocessableEntity
log.Warn(fmt.Sprintf("invalid resource multihash code: %x", decodedMultihash.Code))
log.Warn("invalid resource multihash", "err", err)
return reader, mimeType, status, nil, err
}
manifestAddr = storage.Address(decodedMultihash.Digest)
manifestAddr = storage.Address(decodedMultihash)
log.Trace("resource is multihash", "key", manifestAddr)

// get the manifest the multihash digest points to
Expand Down
5 changes: 1 addition & 4 deletions swarm/api/http/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,7 @@ func TestBzzResourceMultihash(t *testing.T) {
t.Fatal(err)
}
s := common.FromHex(string(b))
mh, err := multihash.Encode(s, multihash.KECCAK_256)
if err != nil {
t.Fatal(err)
}
mh := multihash.ToMultihash(s)

mhHex := hexutil.Encode(mh)
log.Info("added data", "manifest", string(b), "data", common.ToHex(mh))
Expand Down
21 changes: 0 additions & 21 deletions swarm/multihash/LICENSE

This file was deleted.

15 changes: 0 additions & 15 deletions swarm/multihash/Makefile

This file was deleted.

111 changes: 0 additions & 111 deletions swarm/multihash/README.md

This file was deleted.

5 changes: 0 additions & 5 deletions swarm/multihash/README_SWARM.md

This file was deleted.

97 changes: 0 additions & 97 deletions swarm/multihash/io.go

This file was deleted.

Loading

0 comments on commit 3acc595

Please sign in to comment.