api

package
v1.5.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2016 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegularSlashes

func RegularSlashes(path string) (res string)

file system manifest always contains regularized paths no leading or trailing slashes, only single slashes inside

Types

type Api

type Api struct {
	// contains filtered or unexported fields
}

Api implements webserver/file system related content storage and retrieval on top of the dpa it is the public interface of the dpa which is included in the ethereum stack

func NewApi

func NewApi(dpa *storage.DPA, dns Resolver) (self *Api)

the api constructor initialises

func (*Api) Get

func (self *Api) Get(uri string, nameresolver bool) (reader storage.LazySectionReader, mimeType string, status int, err error)

Get uses iterative manifest retrieval and prefix matching to resolve path to content using dpa retrieve it returns a section reader, mimeType, status and an error

func (*Api) Modify

func (self *Api) Modify(uri, contentHash, contentType string, nameresolver bool) (newRootHash string, err error)

func (*Api) Put

func (self *Api) Put(content, contentType string) (string, error)

Put provides singleton manifest creation on top of dpa store

func (*Api) Resolve

func (self *Api) Resolve(hostPort string, nameresolver bool) (storage.Key, error)

DNS Resolver

func (*Api) Retrieve

func (self *Api) Retrieve(key storage.Key) storage.LazySectionReader

DPA reader API

func (*Api) Store

func (self *Api) Store(data io.Reader, size int64, wg *sync.WaitGroup) (key storage.Key, err error)

type Config

type Config struct {
	// serialised/persisted fields
	*storage.StoreParams
	*storage.ChunkerParams
	*network.HiveParams
	Swap *swap.SwapParams
	*network.SyncParams
	Path      string
	Port      string
	PublicKey string
	BzzKey    string
	EnsRoot   common.Address
}

separate bzz directories allow several bzz nodes running in parallel

func NewConfig

func NewConfig(path string, contract common.Address, prvKey *ecdsa.PrivateKey) (self *Config, err error)

config is agnostic to where private key is coming from so managing accounts is outside swarm and left to wrappers

func (*Config) Save

func (self *Config) Save() error

type Control

type Control struct {
	// contains filtered or unexported fields
}

func NewControl

func NewControl(api *Api, hive *network.Hive) *Control

func (*Control) BlockNetworkRead

func (self *Control) BlockNetworkRead(on bool)

func (*Control) Hive

func (self *Control) Hive() string

func (*Control) SwapEnabled

func (self *Control) SwapEnabled(on bool)

func (*Control) SyncEnabled

func (self *Control) SyncEnabled(on bool)

type ErrResolve

type ErrResolve error

type FileSystem

type FileSystem struct {
	// contains filtered or unexported fields
}

func NewFileSystem

func NewFileSystem(api *Api) *FileSystem

func (*FileSystem) Download

func (self *FileSystem) Download(bzzpath, localpath string) error

Download replicates the manifest path structure on the local filesystem under localpath

func (*FileSystem) Upload

func (self *FileSystem) Upload(lpath, index string) (string, error)

Upload replicates a local directory as a manifest file and uploads it using dpa store TODO: localpath should point to a manifest

type Resolver

type Resolver interface {
	Resolve(string) (common.Hash, error)
}

type Response

type Response struct {
	MimeType string
	Status   int
	Size     int64
	// Content  []byte
	Content string
}

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

implements a service

func NewStorage

func NewStorage(api *Api) *Storage

func (*Storage) Get

func (self *Storage) Get(bzzpath string) (*Response, error)

Get retrieves the content from bzzpath and reads the response in full It returns the Response object, which serialises containing the response body as the value of the Content field NOTE: if error is non-nil, sResponse may still have partial content the actual size of which is given in len(resp.Content), while the expected size is resp.Size

func (*Storage) Modify

func (self *Storage) Modify(rootHash, path, contentHash, contentType string) (newRootHash string, err error)

Modify(rootHash, path, contentHash, contentType) takes th e manifest trie rooted in rootHash, and merge on to it. creating an entry w conentType (mime)

func (*Storage) Put

func (self *Storage) Put(content, contentType string) (string, error)

Put uploads the content to the swarm with a simple manifest speficying its content type

Directories

Path Synopsis
A simple http server interface to Swarm
A simple http server interface to Swarm

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL