network

package
v1.6.7 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2017 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version            = 0
	ProtocolLength     = uint64(8)
	ProtocolMaxMsgSize = 10 * 1024 * 1024
	NetworkId          = 3
)
View Source
const (
	Low    = iota // 0
	Medium        // 1
	High          // 2

)

priorities

View Source
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, networkId uint64) (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 added in v1.5.0

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 added in v1.5.0

func NewForwarder(hive *Hive) *forwarder

func Push added in v1.5.0

func Push(p *peer, key storage.Key, priority uint)

push chunk over to peer

Types

type DbAccess added in v1.5.0

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

wrapper of db-s to provide mockable custom local chunk store access to syncer

func NewDbAccess added in v1.5.0

func NewDbAccess(loc *storage.LocalStore) *DbAccess

type Depo added in v1.5.0

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 NewDepo added in v1.5.0

func NewDepo(hash storage.Hasher, localStore, remoteStore storage.ChunkStore) *Depo

func (*Depo) HandleDeliveryRequestMsg added in v1.5.0

func (self *Depo) HandleDeliveryRequestMsg(req *deliveryRequestMsgData, p *peer) error

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 added in v1.5.0

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 added in v1.5.0

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 added in v1.5.0

func (self *Depo) HandleUnsyncedKeysMsg(req *unsyncedKeysMsgData, p *peer) error

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) Addr added in v1.5.0

func (self *Hive) Addr() kademlia.Address

public accessor to the hive base address

func (*Hive) BlockNetworkRead added in v1.5.0

func (self *Hive) BlockNetworkRead(on bool)

func (*Hive) BlockNetworkWrite added in v1.5.0

func (self *Hive) BlockNetworkWrite(on bool)

func (*Hive) DropAll added in v1.5.0

func (self *Hive) DropAll()

disconnects all the peers

func (*Hive) HandlePeersMsg added in v1.5.0

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) Stop

func (self *Hive) Stop() error

func (*Hive) String added in v1.5.0

func (self *Hive) String() string

func (*Hive) SwapEnabled added in v1.5.0

func (self *Hive) SwapEnabled(on bool)

func (*Hive) SyncEnabled added in v1.5.0

func (self *Hive) SyncEnabled(on bool)

type HiveParams

type HiveParams struct {
	CallInterval uint64
	KadDbPath    string
	*kademlia.KadParams
}

func NewHiveParams

func NewHiveParams(path string) *HiveParams

type StorageHandler added in v1.5.0

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 added in v1.5.0

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)

func NewSyncParams added in v1.5.0

func NewSyncParams(bzzdir string) *SyncParams

constructor with default values

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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