diff --git a/swarm/api/storage.go b/swarm/api/storage.go index 8876967792..a2ba70c7ac 100644 --- a/swarm/api/storage.go +++ b/swarm/api/storage.go @@ -16,7 +16,11 @@ package api -import "path" +import ( + "path" + + "github.com/ethereum/go-ethereum/swarm/storage" +) type Response struct { MimeType string @@ -41,13 +45,8 @@ func NewStorage(api *Api) *Storage { // its content type // // DEPRECATED: Use the HTTP API instead -func (self *Storage) Put(content, contentType string) (string, error) { - key, wait, err := self.api.Put(content, contentType) - if err != nil { - return "", err - } - wait() - return key.Hex(), err +func (self *Storage) Put(content, contentType string) (storage.Key, func(), error) { + return self.api.Put(content, contentType) } // Get retrieves the content from bzzpath and reads the response in full diff --git a/swarm/api/storage_test.go b/swarm/api/storage_test.go index d260dd61d8..bcbf53ee37 100644 --- a/swarm/api/storage_test.go +++ b/swarm/api/storage_test.go @@ -31,10 +31,12 @@ func TestStoragePutGet(t *testing.T) { content := "hello" exp := expResponse(content, "text/plain", 0) // exp := expResponse([]byte(content), "text/plain", 0) - bzzhash, err := api.Put(content, exp.MimeType) + bzzkey, wait, err := api.Put(content, exp.MimeType) if err != nil { t.Fatalf("unexpected error: %v", err) } + wait() + bzzhash := bzzkey.Hex() // to check put against the Api#Get resp0 := testGet(t, api.api, bzzhash, "") checkResponse(t, resp0, exp)