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 hubble stack
func (*Api) AppendFile ¶
func (*Api) BuildDirectoryTree ¶
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 ¶
NewManifest creates and stores a new, empty manifest
func (*Api) NewManifestWalker ¶
func (*Api) NewManifestWriter ¶
func (*Api) RemoveFile ¶
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 VnsRoot common.Address VnsAPIs []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 ¶
func NewDefaultConfig() (self *Config)
create a default config with all parameters to set to defaults
func (*Config) Init ¶
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 ¶
type Manifest struct {
Entries []ManifestEntry `json:"entries,omitempty"`
}
Manifest represents a swarm manifest
type ManifestEntry ¶
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 ¶
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 ¶
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 ¶
func (m *ManifestWalker) Walk(walkFn WalkFn) error
Walk recursively walks the manifest calling walkFn for each entry in the manifest, including submanifests
type ManifestWriter ¶
type ManifestWriter struct {
// contains filtered or unexported fields
}
ManifestWriter is used to add and remove entries from an underlying manifest
func (*ManifestWriter) AddEntry ¶
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 ¶
func (m *ManifestWriter) RemoveEntry(path string) error
RemoveEntry removes the given path from the manifest
type MultiResolver ¶
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 ¶
func NewMultiResolver(opts ...MultiResolverOption) (m *MultiResolver)
NewMultiResolver creates a new instance of MultiResolver.
type MultiResolverOption ¶
type MultiResolverOption func(*MultiResolver)
MultiResolverOption sets options for MultiResolver and is used as arguments for its constructor.
func MultiResolverOptionWithResolver ¶
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 ¶
type NoResolverError struct {
TLD string
}
NoResolverError is returned by MultiResolver.Resolve if no resolver can be found for the address.
func NewNoResolverError ¶
func NewNoResolverError(tld string) *NoResolverError
func (*NoResolverError) Error ¶
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 ¶
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 ¶
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 ¶
func (*URI) DeprecatedRaw ¶
type WalkFn ¶
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. |