From 75c8a1835da1c977d175a0f9a35aa93fcb6c07c9 Mon Sep 17 00:00:00 2001 From: Janos Guljas Date: Wed, 13 Dec 2017 12:02:15 +0100 Subject: [PATCH] swarm/api: rename bzzh URL scheme to bzz-hash --- swarm/api/http/server.go | 2 +- swarm/api/http/server_test.go | 4 ++-- swarm/api/uri.go | 8 ++++---- swarm/api/uri_test.go | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/swarm/api/http/server.go b/swarm/api/http/server.go index 0b685b0534..86450ed6f6 100644 --- a/swarm/api/http/server.go +++ b/swarm/api/http/server.go @@ -293,7 +293,7 @@ func (s *Server) HandleDelete(w http.ResponseWriter, r *Request) { // HandleGet handles a GET request to // - bzzr:// and responds with the raw content stored at the // given storage key -// - bzzh:// and responds with the hash of the content stored +// - bzz-hash:// and responds with the hash of the content stored // at the given storage key as a text/plain response func (s *Server) HandleGet(w http.ResponseWriter, r *Request) { key, err := s.api.Resolve(r.uri) diff --git a/swarm/api/http/server_test.go b/swarm/api/http/server_test.go index c60ed611c8..9acfd40979 100644 --- a/swarm/api/http/server_test.go +++ b/swarm/api/http/server_test.go @@ -108,7 +108,7 @@ func TestBzzGetPath(t *testing.T) { var resp *http.Response var respbody []byte - url := srv.URL + "/bzzh:/" + url := srv.URL + "/bzz-hash:/" if k[:] != "" { url += common.ToHex(key[0])[2:] + "/" + k[1:] } @@ -137,7 +137,7 @@ func TestBzzGetPath(t *testing.T) { srv.URL + "/bzz:/name", srv.URL + "/bzzi:/nonhash", srv.URL + "/bzzr:/nonhash", - srv.URL + "/bzzh:/nonhash", + srv.URL + "/bzz-hash:/nonhash", } nonhashresponses := []string{ diff --git a/swarm/api/uri.go b/swarm/api/uri.go index d6951076e7..c28faf7c77 100644 --- a/swarm/api/uri.go +++ b/swarm/api/uri.go @@ -30,7 +30,7 @@ type URI struct { // * bzzr - raw swarm content // * bzzi - immutable URI of an entry in a swarm manifest // (address is not resolved) - // * bzzh - hash of swarm content + // * bzz-hash - hash of swarm content // Scheme string @@ -52,7 +52,7 @@ type URI struct { // * :// // * :/// // -// with scheme one of bzz, bzzr, bzzi or bzzh +// with scheme one of bzz, bzzr, bzzi or bzz-hash func Parse(rawuri string) (*URI, error) { u, err := url.Parse(rawuri) if err != nil { @@ -62,7 +62,7 @@ func Parse(rawuri string) (*URI, error) { // check the scheme is valid switch uri.Scheme { - case "bzz", "bzzi", "bzzr", "bzzh": + case "bzz", "bzzi", "bzzr", "bzz-hash": default: return nil, fmt.Errorf("unknown scheme %q", u.Scheme) } @@ -94,7 +94,7 @@ func (u *URI) Immutable() bool { } func (u *URI) Hash() bool { - return u.Scheme == "bzzh" + return u.Scheme == "bzz-hash" } func (u *URI) String() string { diff --git a/swarm/api/uri_test.go b/swarm/api/uri_test.go index b858bd7d58..0859e78fe8 100644 --- a/swarm/api/uri_test.go +++ b/swarm/api/uri_test.go @@ -97,13 +97,13 @@ func TestParseURI(t *testing.T) { expectURI: &URI{Scheme: "bzz", Addr: "abc123", Path: "path/to/entry"}, }, { - uri: "bzzh:", - expectURI: &URI{Scheme: "bzzh"}, + uri: "bzz-hash:", + expectURI: &URI{Scheme: "bzz-hash"}, expectHash: true, }, { - uri: "bzzh:/", - expectURI: &URI{Scheme: "bzzh"}, + uri: "bzz-hash:/", + expectURI: &URI{Scheme: "bzz-hash"}, expectHash: true, }, }