mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 05:06:43 +00:00
api.put
This commit is contained in:
parent
06fdf4acb3
commit
7355e92dcc
1 changed files with 15 additions and 1 deletions
16
bzz/api.go
16
bzz/api.go
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
|
@ -77,7 +78,20 @@ func (self *Api) Get(bzzpath string) (string, error) {
|
||||||
// Put provides singleton manifest creation and optional name registration
|
// Put provides singleton manifest creation and optional name registration
|
||||||
// on top of dpa store
|
// on top of dpa store
|
||||||
func (self *Api) Put(content, contentType, address, domain string) (string, error) {
|
func (self *Api) Put(content, contentType, address, domain string) (string, error) {
|
||||||
return "", nil
|
sr := io.NewSectionReader(strings.NewReader(content), 0, int64(len(content)))
|
||||||
|
wg := &sync.WaitGroup{}
|
||||||
|
key, err := self.dpa.Store(sr, wg)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
manifest := fmt.Sprintf(`{"entries":[{"hash":"%064x","contentType":"%s"}]}`, key, contentType)
|
||||||
|
sr = io.NewSectionReader(strings.NewReader(manifest), 0, int64(len(manifest)))
|
||||||
|
key, err = self.dpa.Store(sr, wg)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
wg.Wait()
|
||||||
|
return fmt.Sprintf("%064x", key), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Download replicates the manifest path structure on the local filesystem
|
// Download replicates the manifest path structure on the local filesystem
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue