diff options
author | ethersphere <thesw@rm.eth> | 2018-06-20 20:06:27 +0800 |
---|---|---|
committer | ethersphere <thesw@rm.eth> | 2018-06-22 03:10:31 +0800 |
commit | e187711c6545487d4cac3701f0f506bb536234e2 (patch) | |
tree | d2f6150f70b84b36e49a449082aeda267b4b9046 /swarm/api/storage.go | |
parent | 574378edb50c907b532946a1d4654dbd6701b20a (diff) | |
download | dexon-e187711c6545487d4cac3701f0f506bb536234e2.tar.gz dexon-e187711c6545487d4cac3701f0f506bb536234e2.tar.zst dexon-e187711c6545487d4cac3701f0f506bb536234e2.zip |
swarm: network rewrite merge
Diffstat (limited to 'swarm/api/storage.go')
-rw-r--r-- | swarm/api/storage.go | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/swarm/api/storage.go b/swarm/api/storage.go index 0e3abecfe..6ab4af6c4 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 @@ -30,10 +34,10 @@ type Response struct { // // DEPRECATED: Use the HTTP API instead type Storage struct { - api *Api + api *API } -func NewStorage(api *Api) *Storage { +func NewStorage(api *API) *Storage { return &Storage{api} } @@ -41,12 +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, err := self.api.Put(content, contentType) - if err != nil { - return "", err - } - return key.String(), err +func (s *Storage) Put(content, contentType string, toEncrypt bool) (storage.Address, func(), error) { + return s.api.Put(content, contentType, toEncrypt) } // Get retrieves the content from bzzpath and reads the response in full @@ -57,16 +57,16 @@ func (self *Storage) Put(content, contentType string) (string, error) { // size is resp.Size // // DEPRECATED: Use the HTTP API instead -func (self *Storage) Get(bzzpath string) (*Response, error) { +func (s *Storage) Get(bzzpath string) (*Response, error) { uri, err := Parse(path.Join("bzz:/", bzzpath)) if err != nil { return nil, err } - key, err := self.api.Resolve(uri) + addr, err := s.api.Resolve(uri) if err != nil { return nil, err } - reader, mimeType, status, err := self.api.Get(key, uri.Path) + reader, mimeType, status, _, err := s.api.Get(addr, uri.Path) if err != nil { return nil, err } @@ -87,18 +87,18 @@ func (self *Storage) Get(bzzpath string) (*Response, error) { // and merge on to it. creating an entry w conentType (mime) // // DEPRECATED: Use the HTTP API instead -func (self *Storage) Modify(rootHash, path, contentHash, contentType string) (newRootHash string, err error) { +func (s *Storage) Modify(rootHash, path, contentHash, contentType string) (newRootHash string, err error) { uri, err := Parse("bzz:/" + rootHash) if err != nil { return "", err } - key, err := self.api.Resolve(uri) + addr, err := s.api.Resolve(uri) if err != nil { return "", err } - key, err = self.api.Modify(key, path, contentHash, contentType) + addr, err = s.api.Modify(addr, path, contentHash, contentType) if err != nil { return "", err } - return key.String(), nil + return addr.Hex(), nil } |