Documentation
¶
Overview ¶
Package network contains the implementation of network protocol handler for fractal.
Package p2p_handler contains the implementation of p2p handler for fractal.
Package p2p_handler contains the implementation of p2p handler for fractal.
Package network contains the implementation of network protocol handler for fractal.
Package p2p_handler contains the implementation of p2p handler for fractal.
Index ¶
- type BlockWithVerifyFlag
- type NodeInfo
- type Peer
- func (p *Peer) AsyncSendNewBlock(block *types.Block)
- func (p *Peer) AsyncSendTransactions(txs types.Transactions)
- func (p *Peer) AsyncSendTxPackage(pkg *types.TxPackage)
- func (p *Peer) AsyncSendTxPackageHash(pkg *types.TxPackage)
- func (p *Peer) Closed() bool
- func (p *Peer) CompareTo(simpleHash common.Hash, height uint64, round uint64) int
- func (p *Peer) GetID() string
- func (p *Peer) GetPeer() *Peer
- func (p *Peer) GetRW() p2p.MsgReadWriter
- func (p *Peer) Handshake(network uint64, height uint64, round uint64, head common.Hash, ...) error
- func (p *Peer) HasBlock(hash common.Hash) bool
- func (p *Peer) HasTransaction(hash common.Hash) bool
- func (p *Peer) HasTxPackage(hash common.Hash) bool
- func (p *Peer) Head() (fullHash common.Hash, simpleHash common.Hash, height uint64, round uint64)
- func (p *Peer) Info() *PeerInfo
- func (p *Peer) MarkBlock(hash common.Hash)
- func (p *Peer) MarkTransaction(hash common.Hash)
- func (p *Peer) MarkTxPackage(hash common.Hash)
- func (p *Peer) Name() string
- func (p *Peer) RequestBlocksByHash(origin common.Hash, amount int, reverse bool) error
- func (p *Peer) RequestBlocksByRoundRange(roundFrom uint64, roundTo uint64) error
- func (p *Peer) RequestNodeData(hashes []common.Hash) error
- func (p *Peer) RequestOneBlock(hash common.Hash) error
- func (p *Peer) RequestSyncBlocks(stage protocol.SyncStage, roundFrom uint64, roundTo uint64) error
- func (p *Peer) RequestSyncHashList(syncStage protocol.SyncStage, hashType protocol.SyncHashType, ...) error
- func (p *Peer) RequestSyncPkgs(stage protocol.SyncStage, hashes []common.Hash) error
- func (p *Peer) RequestSyncPostBlocksForState(hashEFrom protocol.HashElem, hashETo protocol.HashElem) error
- func (p *Peer) RequestSyncPreBlocksForState(hash common.Hash) error
- func (p *Peer) RequestTxPackage(hash common.Hash) error
- func (p *Peer) SendBlocks(blocks types.Blocks) error
- func (p *Peer) SendNewBlock(block *types.Block) error
- func (p *Peer) SendNodeData(data [][]byte) error
- func (p *Peer) SendSyncBlocks(stage protocol.SyncStage, blocks types.Blocks, roundFrom uint64, ...) error
- func (p *Peer) SendSyncHashList(syncStage protocol.SyncStage, hashType protocol.SyncHashType, ...) error
- func (p *Peer) SendSyncPkgs(fetchPkgsRsp protocol.SyncPkgsRsp) error
- func (p *Peer) SendSyncPostBlocksForState(blocks types.Blocks, pkgs []*types.TxPackage, round uint64, finished bool) error
- func (p *Peer) SendSyncPreBlocksForState(blocks []*types.Block, pkgs []*types.TxPackage) error
- func (p *Peer) SendTransactions(txs types.Transactions) error
- func (p *Peer) SendTxPackage(pkg *types.TxPackage) error
- func (p *Peer) SendTxPackageHash(hash common.Hash) error
- func (p *Peer) SetHead(fullHash common.Hash, simpleHash common.Hash, height uint64, round uint64)
- func (p *Peer) String() string
- type PeerInfo
- type Peers
- func (ps *Peers) Close()
- func (ps *Peers) GetPeers() map[string]*Peer
- func (ps *Peers) Len() int
- func (ps *Peers) Peer(id string) *Peer
- func (ps *Peers) PeersWithTxPackage(hash common.Hash) []*Peer
- func (ps *Peers) PeersWithoutBlock(hash common.Hash) []*Peer
- func (ps *Peers) PeersWithoutTx(hash common.Hash) []*Peer
- func (ps *Peers) PeersWithoutTxPackage(hash common.Hash) []*Peer
- func (ps *Peers) Register(p *Peer) error
- func (ps *Peers) Unregister(id string) error
- type ProtocolManager
- func (pm *ProtocolManager) BroadcastBlock(block *types.Block)
- func (pm *ProtocolManager) BroadcastTxPackage(pkg *types.TxPackage, propagate bool)
- func (pm *ProtocolManager) BroadcastTxs(txs types.Transactions)
- func (pm *ProtocolManager) FinishDepend(p *Peer)
- func (pm *ProtocolManager) GetPacker() packer.Packer
- func (pm *ProtocolManager) MarkDepend(p *Peer)
- func (pm *ProtocolManager) NodeInfo() *NodeInfo
- func (pm *ProtocolManager) RemovePeer(id string, addBlack bool)
- func (pm *ProtocolManager) SetSynchronizer(synchronizer synchronizer)
- func (pm *ProtocolManager) Start(maxPeers int)
- func (pm *ProtocolManager) Stop()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockWithVerifyFlag ¶
type NodeInfo ¶
type NodeInfo struct { Network uint64 `json:"network"` // Fractal network ID (1=Mainnet, 2=Testnet) Height uint64 `json:"Height"` // Height of the host's blockchain Genesis common.Hash `json:"genesis"` // SHA3 Hash of the host's genesis block Head common.Hash `json:"head"` // SHA3 Hash of the host's best owned block }
NodeInfo represents a short summary of the Fractal sub-protocol metadata known about the host
type Peer ¶
func (*Peer) AsyncSendNewBlock ¶
AsyncSendNewBlock queues an entire block for propagation to a remote peer. If the peer's broadcast queue is full, the event is silently dropped.
func (*Peer) AsyncSendTransactions ¶
func (p *Peer) AsyncSendTransactions(txs types.Transactions)
AsyncSendTransactions queues list of transactions propagation to a remote peer. If the peer's broadcast queue is full, the event is silently dropped.
func (*Peer) AsyncSendTxPackage ¶
AsyncSendTxPackage queues tx package propagation to a remote peer. If the peer's broadcast queue is full, the event is silently dropped.
func (*Peer) AsyncSendTxPackageHash ¶
AsyncSendTxPackageHash queues the availability of tx package for propagation to a remote peer. If the peer's broadcast queue is full, the event is silently dropped.
func (*Peer) GetRW ¶
func (p *Peer) GetRW() p2p.MsgReadWriter
func (*Peer) Handshake ¶
func (p *Peer) Handshake(network uint64, height uint64, round uint64, head common.Hash, simpleHash common.Hash, genesis common.Hash) error
Handshake executes the ftl protocol handshake, negotiating version number, network IDs, difficulties, head and genesis blocks.
func (*Peer) HasTransaction ¶
HasTransaction tells whether current peer knows the transaction
func (*Peer) HasTxPackage ¶
HasTxPackage tells whether current peer knows the block
func (*Peer) MarkBlock ¶
MarkBlock marks a block as known for the peer, ensuring that the block will never be propagated to this particular peer.
func (*Peer) MarkTransaction ¶
MarkTransaction marks a transaction as known for the peer, ensuring that it will never be propagated to this particular peer.
func (*Peer) MarkTxPackage ¶
MarkTxPackage marks a tx package as known for the peer, ensuring that the tx package will never be propagated to this particular peer.
func (*Peer) RequestBlocksByHash ¶
RequestBlocksByHash fetches a batch of blocks corresponding to the specified block query, based on the Hash of an origin block.
func (*Peer) RequestBlocksByRoundRange ¶
RequestBlocksByRoundRange fetches a batch of blocks corresponding to the specified block query, based on the Round of an origin block.
func (*Peer) RequestNodeData ¶
RequestNodeData fetches a batch of arbitrary data from a node's known state data, corresponding to the specified hashes.
func (*Peer) RequestOneBlock ¶
RequestOneBlock is a wrapper around the block query functions to fetch a single block. It is used solely by the fetcher.
func (*Peer) RequestSyncBlocks ¶
func (*Peer) RequestSyncHashList ¶
func (*Peer) RequestSyncPkgs ¶
func (*Peer) RequestSyncPostBlocksForState ¶
func (*Peer) RequestSyncPreBlocksForState ¶
RequestSyncBlock fetches blocks for sync
func (*Peer) RequestTxPackage ¶
RequestTxPackage is a wrapper around the tx package query functions to fetch a single tx package.
func (*Peer) SendBlocks ¶
SendBlocks sends a batch of blocks to the remote peer.
func (*Peer) SendNewBlock ¶
SendNewBlock propagates an entire block to a remote peer.
func (*Peer) SendNodeData ¶
SendNodeDataRLP sends a batch of arbitrary internal data, corresponding to the hashes requested.
func (*Peer) SendSyncBlocks ¶
func (*Peer) SendSyncHashList ¶
func (*Peer) SendSyncPkgs ¶
func (p *Peer) SendSyncPkgs(fetchPkgsRsp protocol.SyncPkgsRsp) error
func (*Peer) SendSyncPostBlocksForState ¶
func (*Peer) SendSyncPreBlocksForState ¶
func (*Peer) SendTransactions ¶
func (p *Peer) SendTransactions(txs types.Transactions) error
SendTransactions sends transactions to the peer and includes the hashes in its transaction Hash set for future reference.
func (*Peer) SendTxPackage ¶
SendTxPackage sends tx package to the peer and includes the hashes in its tx package Hash set for future reference.
func (*Peer) SendTxPackageHash ¶
SendTxPackageHash announces the availability of tx package through a Hash notification.
type PeerInfo ¶
type PeerInfo struct { Version int `json:"version"` // Fractal protocol version negotiated Height uint64 `json:"Height"` // Height of the peer's best owned block Round uint64 `json:"Round"` // Round of the peer's best owned block FullHash string `json:"fullHash"` // SHA3 Hash of the peer's best owned block SimpleHash string `json:"simpleHash"` // SHA3 Hash of the peer's best owned block }
PeerInfo represents a short summary of the Fractal sub-protocol metadata known about a connected peer.
type Peers ¶
type Peers struct {
// contains filtered or unexported fields
}
peers represents the collection of active peers
func NewPeers ¶
func NewPeers() *Peers
newPeerSet creates a new peer set top track the active download sources.
func (*Peers) Close ¶
func (ps *Peers) Close()
Close disconnects all peers. No new peers can be registered after Close has returned.
func (*Peers) PeersWithTxPackage ¶
PeersWithTxPackage retrieves a list of peers that have a given tx package in their set of known hashes.
func (*Peers) PeersWithoutBlock ¶
PeersWithoutBlock retrieves a list of peers that do not have a given block in their set of known hashes.
func (*Peers) PeersWithoutTx ¶
PeersWithoutTx retrieves a list of peers that do not have a given transaction in their set of known hashes.
func (*Peers) PeersWithoutTxPackage ¶
PeersWithoutTxPackage retrieves a list of peers that do not have a given tx package in their set of known hashes.
func (*Peers) Register ¶
Register injects a new peer into the working set, or returns an error if the peer is already known. If a new peer it registered, its broadcast loop is also started.
func (*Peers) Unregister ¶
Unregister removes a remote peer from the active set, disabling any further actions to/from that particular entity.
type ProtocolManager ¶
type ProtocolManager struct { // protocols SubProtocols []p2p.Protocol BlockProcessCh chan *BlockWithVerifyFlag // contains filtered or unexported fields }
func NewProtocolManager ¶
func NewProtocolManager(networkID uint64, miner Miner.Miner, blockchain blockChain, packer packer.Packer, txpool pool.Pool, txPkgPool pool.Pool) (*ProtocolManager, error)
NewProtocolManager returns a new Fractal sub protocol manager. The Fractal sub protocol manages peers capable with the Fractal network.
func (*ProtocolManager) BroadcastBlock ¶
func (pm *ProtocolManager) BroadcastBlock(block *types.Block)
BroadcastBlock will propagate a block to all neighbors
func (*ProtocolManager) BroadcastTxPackage ¶
func (pm *ProtocolManager) BroadcastTxPackage(pkg *types.TxPackage, propagate bool)
BroadcastTxPackage will either propagate a tx package to it's peers, or will only announce it's availability (depending what's requested).
func (*ProtocolManager) BroadcastTxs ¶
func (pm *ProtocolManager) BroadcastTxs(txs types.Transactions)
BroadcastTxs will propagate a batch of transactions to all peers which are not known to already have the given transaction.
func (*ProtocolManager) FinishDepend ¶
func (pm *ProtocolManager) FinishDepend(p *Peer)
func (*ProtocolManager) GetPacker ¶
func (pm *ProtocolManager) GetPacker() packer.Packer
func (*ProtocolManager) MarkDepend ¶
func (pm *ProtocolManager) MarkDepend(p *Peer)
func (*ProtocolManager) NodeInfo ¶
func (pm *ProtocolManager) NodeInfo() *NodeInfo
NodeInfo retrieves some protocol metadata about the running host node.
func (*ProtocolManager) RemovePeer ¶
func (pm *ProtocolManager) RemovePeer(id string, addBlack bool)
func (*ProtocolManager) SetSynchronizer ¶
func (pm *ProtocolManager) SetSynchronizer(synchronizer synchronizer)
func (*ProtocolManager) Start ¶
func (pm *ProtocolManager) Start(maxPeers int)
func (*ProtocolManager) Stop ¶
func (pm *ProtocolManager) Stop()