Documentation ¶
Index ¶
- Constants
- func Bzz(cloud StorageHandler, backend chequebook.Backend, hive *Hive, ...) (p2p.Protocol, error)
- func Deliver(p *peer, req interface{}, ty int)
- func NewForwarder(hive *Hive) *forwarder
- func Push(p *peer, key storage.Key, priority uint)
- type DbAccess
- type Depo
- func (self *Depo) HandleDeliveryRequestMsg(req *deliveryRequestMsgData, p *peer) error
- func (self *Depo) HandleRetrieveRequestMsg(req *retrieveRequestMsgData, p *peer)
- func (self *Depo) HandleStoreRequestMsg(req *storeRequestMsgData, p *peer)
- func (self *Depo) HandleUnsyncedKeysMsg(req *unsyncedKeysMsgData, p *peer) error
- type Hive
- func (self *Hive) Addr() kademlia.Address
- func (self *Hive) BlockNetworkRead(on bool)
- func (self *Hive) BlockNetworkWrite(on bool)
- func (self *Hive) DropAll()
- func (self *Hive) HandlePeersMsg(req *peersMsgData, from *peer)
- func (self *Hive) Start(id discover.NodeID, listenAddr func() string, connectPeer func(string) error) (err error)
- func (self *Hive) Stop() error
- func (self *Hive) String() string
- func (self *Hive) SwapEnabled(on bool)
- func (self *Hive) SyncEnabled(on bool)
- type HiveParams
- type StorageHandler
- type SyncParams
Constants ¶
const ( Version = 0 ProtocolLength = uint64(8) ProtocolMaxMsgSize = 10 * 1024 * 1024 NetworkId = 322 )
const ( ErrMsgTooLarge = iota ErrDecode ErrInvalidMsgCode ErrVersionMismatch ErrNetworkIdMismatch ErrNoStatusMsg ErrExtraStatusMsg ErrSwap ErrSync ErrUnwanted )
const ( Low = iota // 0 Medium // 1 High // 2 )
priorities
const ( DeliverReq = iota // 0 PushReq // 1 PropagateReq // 2 HistoryReq // 3 BacklogReq // 4 )
request types
Variables ¶
This section is empty.
Functions ¶
func Bzz ¶
func Bzz(cloud StorageHandler, backend chequebook.Backend, hive *Hive, dbaccess *DbAccess, sp *bzzswap.SwapParams, sy *SyncParams) (p2p.Protocol, error)
main entrypoint, wrappers starting a server that will run the bzz protocol use this constructor to attach the protocol ("class") to server caps This is done by node.Node#Register(func(node.ServiceContext) (Service, error)) Service implements Protocols() which is an array of protocol constructors at node startup the protocols are initialised the Dev p2p layer then calls Run(p *p2p.Peer, rw p2p.MsgReadWriter) error on each peer connection The Run function of the Bzz protocol class creates a bzz instance which will represent the peer for the swarm hive and all peer-aware components
func Deliver ¶
func Deliver(p *peer, req interface{}, ty int)
initiate delivery of a chunk to a particular peer via syncer#addRequest depending on syncer mode and priority settings and sync request type this either goes via confirmation roundtrip or queued or pushed directly
func NewForwarder ¶
func NewForwarder(hive *Hive) *forwarder
Types ¶
type DbAccess ¶
type DbAccess struct {
// contains filtered or unexported fields
}
wrapper of db-s to provide mockable custom local chunk store access to syncer
func NewDbAccess ¶
func NewDbAccess(loc *storage.LocalStore) *DbAccess
type Depo ¶
type Depo struct {
// contains filtered or unexported fields
}
Handler for storage/retrieval related protocol requests implements the StorageHandler interface used by the bzz protocol
func (*Depo) HandleDeliveryRequestMsg ¶
Handles deliveryRequestMsg * serves actual chunks asked by the remote peer by pushing to the delivery queue (sync db) of the correct priority (remote peer is free to reprioritize) * the message implies remote peer wants more, so trigger for * new outgoing unsynced keys message is fired
func (*Depo) HandleRetrieveRequestMsg ¶
func (self *Depo) HandleRetrieveRequestMsg(req *retrieveRequestMsgData, p *peer)
entrypoint for retrieve requests coming from the bzz wire protocol checks swap balance - return if peer has no credit
func (*Depo) HandleStoreRequestMsg ¶
func (self *Depo) HandleStoreRequestMsg(req *storeRequestMsgData, p *peer)
the entrypoint for store requests coming from the bzz wire protocol if key found locally, return. otherwise remote is untrusted, so hash is verified and chunk passed on to NetStore
func (*Depo) HandleUnsyncedKeysMsg ¶
Handles UnsyncedKeysMsg after msg decoding - unsynced hashes upto sync state * the remote sync state is just stored and handled in protocol * filters through the new syncRequests and send the ones missing * back immediately as a deliveryRequest message * empty message just pings back for more (is this needed?) * strict signed sync states may be needed.
type Hive ¶
type Hive struct {
// contains filtered or unexported fields
}
func NewHive ¶
func NewHive(addr common.Hash, params *HiveParams, swapEnabled, syncEnabled bool) *Hive
func (*Hive) BlockNetworkRead ¶
func (*Hive) BlockNetworkWrite ¶
func (*Hive) HandlePeersMsg ¶
func (self *Hive) HandlePeersMsg(req *peersMsgData, from *peer)
called by the protocol when receiving peerset (for target address) peersMsgData is converted to a slice of NodeRecords for Kademlia this is to store all thats needed
func (*Hive) Start ¶
func (self *Hive) Start(id discover.NodeID, listenAddr func() string, connectPeer func(string) error) (err error)
Start receives network info only at startup listedAddr is a function to retrieve listening address to advertise to peers connectPeer is a function to connect to a peer based on its NodeID or enode URL there are called on the p2p.Server which runs on the node
func (*Hive) SwapEnabled ¶
func (*Hive) SyncEnabled ¶
type HiveParams ¶
func NewHiveParams ¶
func NewHiveParams(path string) *HiveParams
type StorageHandler ¶
type StorageHandler interface { HandleUnsyncedKeysMsg(req *unsyncedKeysMsgData, p *peer) error HandleDeliveryRequestMsg(req *deliveryRequestMsgData, p *peer) error HandleStoreRequestMsg(req *storeRequestMsgData, p *peer) HandleRetrieveRequestMsg(req *retrieveRequestMsgData, p *peer) }
interface type for handler of storage/retrieval related requests coming via the bzz wire protocol messages: UnsyncedKeys, DeliveryRequest, StoreRequest, RetrieveRequest
type SyncParams ¶
type SyncParams struct { RequestDbPath string // path for request db (leveldb) RequestDbBatchSize uint // nuber of items before batch is saved to requestdb KeyBufferSize uint // size of key buffer SyncBatchSize uint // maximum batchsize for outgoing requests SyncBufferSize uint // size of buffer for SyncCacheSize uint // cache capacity to store request queue in memory SyncPriorities []uint // list of priority levels for req types 0-3 SyncModes []bool // list of sync modes for for req types 0-3 }
syncer parameters (global, not peer specific)