Documentation ¶
Index ¶
- Variables
- type GetTransaction
- type Manager
- func (m *Manager) AddInbound(p *peer.Peer) error
- func (m *Manager) AddOutbound(p *peer.Peer) error
- func (m *Manager) Close()
- func (m *Manager) DropNeighbor(id peer.ID) error
- func (m *Manager) RequestTransaction(txHash []byte, to ...peer.ID)
- func (m *Manager) SendTransaction(txData []byte, to ...peer.ID)
- type NeighborDroppedEvent
- type RequestTransactionEvent
- type TransactionReceivedEvent
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrClosed = errors.New("manager closed") ErrNotANeighbor = errors.New("peer is not a neighbor") ErrDuplicateNeighbor = errors.New("peer already connected") )
View Source
var Events = struct { // A TransactionReceived event is triggered when a new transaction is received by the gossip protocol. TransactionReceived *events.Event // A NeighborDropped event is triggered when a neighbor has been dropped. NeighborDropped *events.Event // A RequestTransaction should be triggered for a transaction to be requested through the gossip protocol. RequestTransaction *events.Event }{ TransactionReceived: events.NewEvent(transactionReceived), NeighborDropped: events.NewEvent(neighborDropped), RequestTransaction: events.NewEvent(requestTransaction), }
Events contains all the events related to the gossip protocol.
Functions ¶
This section is empty.
Types ¶
type GetTransaction ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager(t *transport.TCP, log *zap.SugaredLogger, f GetTransaction) *Manager
func (*Manager) AddInbound ¶
AddInbound tries to add a neighbor by accepting an incoming connection from that peer.
func (*Manager) AddOutbound ¶
AddOutbound tries to add a neighbor by connecting to that peer.
func (*Manager) Close ¶
func (m *Manager) Close()
Close stops the manager and closes all established connections.
func (*Manager) DropNeighbor ¶
NeighborDropped disconnects the neighbor with the given ID.
func (*Manager) RequestTransaction ¶
RequestTransaction requests the transaction with the given hash from the neighbors. If no peer is provided, all neighbors are queried.
type NeighborDroppedEvent ¶
type RequestTransactionEvent ¶
type RequestTransactionEvent struct {
Hash []byte // hash of the transaction to request
}
Click to show internal directories.
Click to hide internal directories.