Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DecodedMessage ¶
func DefaultRPCDecodeFunc ¶
func DefaultRPCDecodeFunc(rpc RPC) (*DecodedMessage, error)
type LocalTransport ¶
type LocalTransport struct {
Peers map[NetAddr]*LocalTransport
Lock sync.RWMutex
ConsumeCh chan RPC
// contains filtered or unexported fields
}
func (*LocalTransport) Addr ¶
func (t *LocalTransport) Addr() NetAddr
func (*LocalTransport) Broadcast ¶
func (t *LocalTransport) Broadcast(payload []byte) error
func (*LocalTransport) Connect ¶
func (t *LocalTransport) Connect(tr Transport) error
func (*LocalTransport) Consume ¶
func (t *LocalTransport) Consume() <-chan RPC
func (*LocalTransport) SendMessage ¶
func (t *LocalTransport) SendMessage(to NetAddr, payload []byte) error
type Message ¶
type Message struct {
Header MessageType
Data []byte
}
func NewMessage ¶
func NewMessage(t MessageType, data []byte) *Message
type RPCDecodeFunc ¶
type RPCDecodeFunc func(RPC) (*DecodedMessage, error)
type RPCProcessor ¶
type RPCProcessor interface {
ProcessMessage(*DecodedMessage) error
}
type Server ¶
type Server struct {
ServerOpts
MemPool *TxPool
IsValidator bool
RpcCh chan RPC
QuitChan chan struct{}
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(opts ServerOpts) (*Server, error)
func (*Server) CreateNewBlock ¶
func (*Server) ProcessMessage ¶
func (s *Server) ProcessMessage(message *DecodedMessage) error
func (*Server) ValidatorLoop ¶
func (s *Server) ValidatorLoop()
type ServerOpts ¶
type ServerOpts struct {
ID string
Logger log.Logger
// RPCHandler is responsible for handling remote procedure calls (RPCs)
// within the network server. It defines the methods and logic required
// to process incoming RPC requests and send appropriate responses.
RPCDecodeFunc RPCDecodeFunc
RPCProcessor RPCProcessor
Transports []Transport
PrivateKey *crypto.PrivateKey
BlockTime time.Duration
}
type Transport ¶
type Transport interface {
Consume() <-chan RPC
Connect(Transport) error
SendMessage(NetAddr, []byte) error
Addr() NetAddr
Broadcast([]byte) error
}
func NewLocalTransport ¶
type TxMapSorter ¶
type TxMapSorter struct {
Transations []*core.Transaction
}
func NewTxMapSorter ¶
func NewTxMapSorter(txMap map[types.Hash]*core.Transaction) *TxMapSorter
func (*TxMapSorter) Len ¶
func (s *TxMapSorter) Len() int
type TxPool ¶
type TxPool struct {
// contains filtered or unexported fields
}
func (*TxPool) Add ¶
func (p *TxPool) Add(tx *core.Transaction) error
Add adds a transaction to the pool. The caller is responsible for checking if the transaction already exists in the pool.
func (*TxPool) Transactions ¶
func (p *TxPool) Transactions() []*core.Transaction
Transactions returns a slice of all transactions in the pool.
Click to show internal directories.
Click to hide internal directories.