Documentation ¶
Index ¶
- type Info
- type Swarm
- func (self *Swarm) API() *SwarmAPI
- func (self *Swarm) APIs() []rpc.API
- func (self *Swarm) Api() *api.API
- func (self *Swarm) Protocols() (protos []p2p.Protocol)
- func (self *Swarm) RegisterPssProtocol(spec *protocols.Spec, targetprotocol *p2p.Protocol, ...) (*pss.Protocol, error)
- func (self *Swarm) SetChequebook(ctx context.Context) error
- func (self *Swarm) Start(srv *p2p.Server) error
- func (self *Swarm) Stop() error
- type SwarmAPI
- type Voidstore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Swarm ¶
type Swarm struct {
// contains filtered or unexported fields
}
the swarm stack
func NewSwarm ¶
creates a new swarm service instance implements node.Service If mockStore is not nil, it will be used as the storage for chunk data. MockStore should be used only for testing.
func (*Swarm) APIs ¶
implements node.Service APIs returns the RPC API descriptors the Swarm implementation offers
func (*Swarm) RegisterPssProtocol ¶
func (*Swarm) SetChequebook ¶
SetChequebook ensures that the local checquebook is set up on chain.
func (*Swarm) Start ¶
Start is called when the stack is started * starts the network kademlia hive peer management * (starts netStore level 0 api) * starts DPA level 1 api (chunking -> store/retrieve requests) * (starts level 2 api) * starts http proxy server * registers url scheme handlers for bzz, etc * TODO: start subservices like sword, swear, swarmdns
implements the node.Service interface
Directories ¶
Path | Synopsis |
---|---|
http
A simple http server interface to Swarm
|
A simple http server interface to Swarm |
Package bmt provides a binary merkle tree implementation used for swarm chunk hash Package bmt is a simple nonconcurrent reference implementation for hashsize segment based Binary Merkle tree hash on arbitrary but fixed maximum chunksize This implementation does not take advantage of any paralellisms and uses far more memory than necessary, but it is easy to see that it is correct.
|
Package bmt provides a binary merkle tree implementation used for swarm chunk hash Package bmt is a simple nonconcurrent reference implementation for hashsize segment based Binary Merkle tree hash on arbitrary but fixed maximum chunksize This implementation does not take advantage of any paralellisms and uses far more memory than necessary, but it is easy to see that it is correct. |
simulations
You can run this simulation using go run ./swarm/network/simulations/overlay.go
|
You can run this simulation using go run ./swarm/network/simulations/overlay.go |
Package pot see doc.go Package pot (proximity order tree) implements a container similar to a binary tree.
|
Package pot see doc.go Package pot (proximity order tree) implements a container similar to a binary tree. |
Pss provides devp2p functionality for swarm nodes without the need for a direct tcp connection between them.
|
Pss provides devp2p functionality for swarm nodes without the need for a direct tcp connection between them. |
client
simple abstraction for implementing pss functionality the pss client library aims to simplify usage of the p2p.protocols package over pss IO is performed using the ordinary p2p.MsgReadWriter interface, which transparently communicates with a pss node via RPC using websockets as transport layer, using methods in the PssAPI class in the swarm/pss package Minimal-ish usage example (requires a running pss node with websocket RPC): import ( "context" "fmt" "os" pss "github.com/ovcharovvladimir/essentiaHybrid/swarm/pss/client" "github.com/ovcharovvladimir/essentiaHybrid/p2p/protocols" "github.com/ovcharovvladimir/essentiaHybrid/p2p" "github.com/ovcharovvladimir/essentiaHybrid/swarm/pot" "github.com/ovcharovvladimir/essentiaHybrid/swarm/log" ) type FooMsg struct { Bar int } func fooHandler (msg interface{}) error { foomsg, ok := msg.(*FooMsg) if ok { log.Debug("Yay, just got a message", "msg", foomsg) } return errors.New(fmt.Sprintf("Unknown message")) } spec := &protocols.Spec{ Name: "foo", Version: 1, MaxMsgSize: 1024, Messages: []interface{}{ FooMsg{}, }, } proto := &p2p.Protocol{ Name: spec.Name, Version: spec.Version, Length: uint64(len(spec.Messages)), Run: func(p *p2p.Peer, rw p2p.MsgReadWriter) error { pp := protocols.NewPeer(p, rw, spec) return pp.Run(fooHandler) }, } func implementation() { cfg := pss.NewClientConfig() psc := pss.NewClient(context.Background(), nil, cfg) err := psc.Start() if err != nil { log.Crit("can't start pss client") os.Exit(1) } log.Debug("connected to pss node", "bzz addr", psc.BaseAddr) err = psc.RunProtocol(proto) if err != nil { log.Crit("can't start protocol on pss websocket") os.Exit(1) } addr := pot.RandomAddress() // should be a real address, of course psc.AddPssPeer(addr, spec) // use the protocol for something psc.Stop() } BUG(test): TestIncoming test times out due to deadlock issues in the swarm hive
|
simple abstraction for implementing pss functionality the pss client library aims to simplify usage of the p2p.protocols package over pss IO is performed using the ordinary p2p.MsgReadWriter interface, which transparently communicates with a pss node via RPC using websockets as transport layer, using methods in the PssAPI class in the swarm/pss package Minimal-ish usage example (requires a running pss node with websocket RPC): import ( "context" "fmt" "os" pss "github.com/ovcharovvladimir/essentiaHybrid/swarm/pss/client" "github.com/ovcharovvladimir/essentiaHybrid/p2p/protocols" "github.com/ovcharovvladimir/essentiaHybrid/p2p" "github.com/ovcharovvladimir/essentiaHybrid/swarm/pot" "github.com/ovcharovvladimir/essentiaHybrid/swarm/log" ) type FooMsg struct { Bar int } func fooHandler (msg interface{}) error { foomsg, ok := msg.(*FooMsg) if ok { log.Debug("Yay, just got a message", "msg", foomsg) } return errors.New(fmt.Sprintf("Unknown message")) } spec := &protocols.Spec{ Name: "foo", Version: 1, MaxMsgSize: 1024, Messages: []interface{}{ FooMsg{}, }, } proto := &p2p.Protocol{ Name: spec.Name, Version: spec.Version, Length: uint64(len(spec.Messages)), Run: func(p *p2p.Peer, rw p2p.MsgReadWriter) error { pp := protocols.NewPeer(p, rw, spec) return pp.Run(fooHandler) }, } func implementation() { cfg := pss.NewClientConfig() psc := pss.NewClient(context.Background(), nil, cfg) err := psc.Start() if err != nil { log.Crit("can't start pss client") os.Exit(1) } log.Debug("connected to pss node", "bzz addr", psc.BaseAddr) err = psc.RunProtocol(proto) if err != nil { log.Crit("can't start protocol on pss websocket") os.Exit(1) } addr := pot.RandomAddress() // should be a real address, of course psc.AddPssPeer(addr, spec) // use the protocol for something psc.Stop() } BUG(test): TestIncoming test times out due to deadlock issues in the swarm hive |
services
|
|
feed
Package feeds defines Swarm Feeds.
|
Package feeds defines Swarm Feeds. |
feed/lookup
Package lookup defines feed lookup algorithms and provides tools to place updates so they can be found
|
Package lookup defines feed lookup algorithms and provides tools to place updates so they can be found |
mock
Package mock defines types that are used by different implementations of mock storages.
|
Package mock defines types that are used by different implementations of mock storages. |
mock/db
Package db implements a mock store that keeps all chunk data in LevelDB database.
|
Package db implements a mock store that keeps all chunk data in LevelDB database. |
mock/mem
Package mem implements a mock store that keeps all chunk data in memory.
|
Package mem implements a mock store that keeps all chunk data in memory. |
mock/rpc
Package rpc implements an RPC client that connect to a centralized mock store.
|
Package rpc implements an RPC client that connect to a centralized mock store. |
mock/test
Package test provides functions that are used for testing GlobalStorer implementations.
|
Package test provides functions that are used for testing GlobalStorer implementations. |