swarm/api: fix deprecated Storage.Put to return wait function

This commit is contained in:
Anton Evangelatov 2018-02-12 13:03:07 +01:00
parent c0924c4764
commit 5d30973288
2 changed files with 10 additions and 9 deletions

View file

@ -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

View file

@ -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)