Documentation ¶
Index ¶
- Constants
- Variables
- func RegularSlashes(path string) (res string)
- type Api
- func (self *Api) AddFile(mhash, path, fname string, content []byte, nameresolver bool) (storage.Key, string, error)
- func (self *Api) AppendFile(mhash, path, fname string, existingSize int64, content []byte, ...) (storage.Key, string, error)
- func (self *Api) BuildDirectoryTree(mhash string, nameresolver bool) (key storage.Key, manifestEntryMap map[string]*manifestTrieEntry, err error)
- func (self *Api) Get(key storage.Key, path string) (reader storage.LazySectionReader, mimeType string, status int, err error)
- func (self *Api) Modify(key storage.Key, path, contentHash, contentType string) (storage.Key, error)
- func (a *Api) NewManifest() (storage.Key, error)
- func (a *Api) NewManifestWalker(key storage.Key, quitC chan bool) (*ManifestWalker, error)
- func (a *Api) NewManifestWriter(key storage.Key, quitC chan bool) (*ManifestWriter, error)
- func (self *Api) Put(content, contentType string) (storage.Key, error)
- func (self *Api) RemoveFile(mhash, path, fname string, nameresolver bool) (string, error)
- func (self *Api) Resolve(uri *URI) (storage.Key, error)
- func (self *Api) Retrieve(key storage.Key) storage.LazySectionReader
- func (self *Api) Store(data io.Reader, size int64, wg *sync.WaitGroup) (key storage.Key, err error)
- func (self *Api) Upload(uploadDir, index string) (hash string, err error)
- type Config
- type Control
- type ErrResolve
- type FileSystem
- type Manifest
- type ManifestEntry
- type ManifestList
- type ManifestWalker
- type ManifestWriter
- type MultiResolver
- type MultiResolverOption
- type NoResolverError
- type Resolver
- type Response
- type Storage
- type URI
- type WalkFn
Constants ¶
const ( DefaultHTTPListenAddr = "127.0.0.1" DefaultHTTPPort = "8500" )
const (
ManifestType = "application/bzz-manifest+json"
)
Variables ¶
var SkipManifest = errors.New("skip this manifest")
SkipManifest is used as a return value from WalkFn to indicate that the manifest should be skipped
Functions ¶
func RegularSlashes ¶
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 (*Api) AppendFile ¶ added in v1.6.0
func (*Api) BuildDirectoryTree ¶ added in v1.6.0
func (*Api) Get ¶
func (self *Api) Get(key storage.Key, path string) (reader storage.LazySectionReader, mimeType string, status int, err error)
Get uses iterative manifest retrieval and prefix matching to resolve basePath to content using dpa retrieve it returns a section reader, mimeType, status and an error
func (*Api) NewManifest ¶ added in v1.6.0
NewManifest creates and stores a new, empty manifest
func (*Api) NewManifestWalker ¶ added in v1.6.0
func (*Api) NewManifestWriter ¶ added in v1.6.0
func (*Api) RemoveFile ¶ added in v1.6.0
func (*Api) Retrieve ¶
func (self *Api) Retrieve(key storage.Key) storage.LazySectionReader
DPA reader API
type Config ¶
type Config struct { // serialised/persisted fields *storage.StoreParams *storage.ChunkerParams *network.HiveParams Swap *swap.SwapParams *network.SyncParams Contract common.Address EnsRoot common.Address EnsAPIs []string Path string ListenAddr string Port string PublicKey string BzzKey string NetworkId uint64 SwapEnabled bool SyncEnabled bool SwapApi string Cors string BzzAccount string BootNodes string }
separate bzz directories allow several bzz nodes running in parallel
func NewDefaultConfig ¶ added in v1.8.0
func NewDefaultConfig() (self *Config)
create a default config with all parameters to set to defaults
func (*Config) Init ¶ added in v1.8.0
func (self *Config) Init(prvKey *ecdsa.PrivateKey)
some config params need to be initialized after the complete config building phase is completed (e.g. due to overriding flags)
type Control ¶
type Control struct {
// contains filtered or unexported fields
}
func (*Control) BlockNetworkRead ¶
func (*Control) SwapEnabled ¶
func (*Control) SyncEnabled ¶
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 basePath structure on the local filesystem under localpath
DEPRECATED: Use the HTTP API instead
type Manifest ¶ added in v1.6.0
type Manifest struct {
Entries []ManifestEntry `json:"entries,omitempty"`
}
Manifest represents a swarm manifest
type ManifestEntry ¶ added in v1.6.0
type ManifestEntry struct { Hash string `json:"hash,omitempty"` Path string `json:"path,omitempty"` ContentType string `json:"contentType,omitempty"` Mode int64 `json:"mode,omitempty"` Size int64 `json:"size,omitempty"` ModTime time.Time `json:"mod_time,omitempty"` Status int `json:"status,omitempty"` }
ManifestEntry represents an entry in a swarm manifest
type ManifestList ¶ added in v1.6.0
type ManifestList struct { CommonPrefixes []string `json:"common_prefixes,omitempty"` Entries []*ManifestEntry `json:"entries,omitempty"` }
ManifestList represents the result of listing files in a manifest
type ManifestWalker ¶ added in v1.6.0
type ManifestWalker struct {
// contains filtered or unexported fields
}
ManifestWalker is used to recursively walk the entries in the manifest and all of its submanifests
func (*ManifestWalker) Walk ¶ added in v1.6.0
func (m *ManifestWalker) Walk(walkFn WalkFn) error
Walk recursively walks the manifest calling walkFn for each entry in the manifest, including submanifests
type ManifestWriter ¶ added in v1.6.0
type ManifestWriter struct {
// contains filtered or unexported fields
}
ManifestWriter is used to add and remove entries from an underlying manifest
func (*ManifestWriter) AddEntry ¶ added in v1.6.0
func (m *ManifestWriter) AddEntry(data io.Reader, e *ManifestEntry) (storage.Key, error)
AddEntry stores the given data and adds the resulting key to the manifest
func (*ManifestWriter) RemoveEntry ¶ added in v1.6.0
func (m *ManifestWriter) RemoveEntry(path string) error
RemoveEntry removes the given path from the manifest
type MultiResolver ¶ added in v1.8.2
type MultiResolver struct {
// contains filtered or unexported fields
}
MultiResolver is used to resolve URL addresses based on their TLDs. Each TLD can have multiple resolvers, and the resoluton from the first one in the sequence will be returned.
func NewMultiResolver ¶ added in v1.8.2
func NewMultiResolver(opts ...MultiResolverOption) (m *MultiResolver)
NewMultiResolver creates a new instance of MultiResolver.
func (MultiResolver) Resolve ¶ added in v1.8.2
func (m MultiResolver) Resolve(addr string) (h common.Hash, err error)
Resolve resolves address by choosing a Resolver by TLD. If there are more default Resolvers, or for a specific TLD, the Hash from the the first one which does not return error will be returned.
type MultiResolverOption ¶ added in v1.8.2
type MultiResolverOption func(*MultiResolver)
MultiResolverOption sets options for MultiResolver and is used as arguments for its constructor.
func MultiResolverOptionWithResolver ¶ added in v1.8.2
func MultiResolverOptionWithResolver(r Resolver, tld string) MultiResolverOption
MultiResolverOptionWithResolver adds a Resolver to a list of resolvers for a specific TLD. If TLD is an empty string, the resolver will be added to the list of default resolver, the ones that will be used for resolution of addresses which do not have their TLD resolver specified.
type NoResolverError ¶ added in v1.8.2
type NoResolverError struct {
TLD string
}
NoResolverError is returned by MultiResolver.Resolve if no resolver can be found for the address.
func NewNoResolverError ¶ added in v1.8.2
func NewNoResolverError(tld string) *NoResolverError
func (*NoResolverError) Error ¶ added in v1.8.2
func (e *NoResolverError) Error() string
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
implements a service
DEPRECATED: Use the HTTP API instead
func NewStorage ¶
func (*Storage) Get ¶
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
DEPRECATED: Use the HTTP API instead
func (*Storage) Modify ¶
func (self *Storage) Modify(rootHash, path, contentHash, contentType string) (newRootHash string, err error)
Modify(rootHash, basePath, contentHash, contentType) takes th e manifest trie rooted in rootHash, and merge on to it. creating an entry w conentType (mime)
DEPRECATED: Use the HTTP API instead
type URI ¶ added in v1.6.0
type URI struct { // Scheme has one of the following values: // // * bzz - an entry in a swarm manifest // * bzz-raw - raw swarm content // * bzz-immutable - immutable URI of an entry in a swarm manifest // (address is not resolved) // * bzz-list - list of all files contained in a swarm manifest // // Deprecated Schemes: // * bzzr - raw swarm content // * bzzi - immutable URI of an entry in a swarm manifest // (address is not resolved) // * bzz-hash - hash of swarm content // Scheme string // Addr is either a hexadecimal storage key or it an address which // resolves to a storage key Addr string // Path is the path to the content within a swarm manifest Path string }
URI is a reference to content stored in swarm.
func Parse ¶ added in v1.5.8
Parse parses rawuri into a URI struct, where rawuri is expected to have one of the following formats:
* <scheme>:/ * <scheme>:/<addr> * <scheme>:/<addr>/<path> * <scheme>:// * <scheme>://<addr> * <scheme>://<addr>/<path>
with scheme one of bzz, bzz-raw, bzz-immutable, bzz-list or bzz-hash or deprecated ones bzzr and bzzi
func (*URI) DeprecatedImmutable ¶ added in v1.8.0
func (*URI) DeprecatedRaw ¶ added in v1.8.0
type WalkFn ¶ added in v1.6.0
type WalkFn func(entry *ManifestEntry) error
WalkFn is the type of function called for each entry visited by a recursive manifest walk
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Show nicely (but simple) formatted HTML error pages (or respond with JSON if the appropriate `Accept` header is set)) for the http package.
|
Show nicely (but simple) formatted HTML error pages (or respond with JSON if the appropriate `Accept` header is set)) for the http package. |