Documentation ¶
Index ¶
- type BlocksMessage
- type DecodedMessage
- type GetBlocksMessage
- type GetStatusMessage
- type LocalTransport
- type Message
- type MessageType
- type NetAddr
- type RPC
- type RPCDecodeFunc
- type RPCProcessor
- type Server
- type ServerOpts
- type StatusMessage
- type TCPPeer
- type TCPTransport
- type Transport
- type TxPool
- type TxSortedMap
- func (t *TxSortedMap) Add(tx *core.Transaction)
- func (t *TxSortedMap) Clear()
- func (t *TxSortedMap) Contains(h types.Hash) bool
- func (t *TxSortedMap) Count() int
- func (t *TxSortedMap) First() *core.Transaction
- func (t *TxSortedMap) Get(h types.Hash) *core.Transaction
- func (t *TxSortedMap) Remove(h types.Hash)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlocksMessage ¶
type DecodedMessage ¶
func DefaultRPCDecodeFunc ¶
func DefaultRPCDecodeFunc(rpc RPC) (*DecodedMessage, error)
type GetBlocksMessage ¶
type GetStatusMessage ¶
type GetStatusMessage struct{}
type LocalTransport ¶
type LocalTransport struct {
// contains filtered or unexported fields
}
func NewLocalTransport ¶
func NewLocalTransport(addr net.Addr) *LocalTransport
func (*LocalTransport) Addr ¶
func (t *LocalTransport) Addr() net.Addr
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 net.Addr, payload []byte) error
type Message ¶
type Message struct { Header MessageType Data []byte }
func NewMessage ¶
func NewMessage(t MessageType, data []byte) *Message
type MessageType ¶
type MessageType byte
const ( MessageTypeTx MessageType = 0x1 MessageTypeBlock MessageType = 0x2 MessageTypeGetBlocks MessageType = 0x3 MessageTypeStatus MessageType = 0x4 MessageTypeGetStatus MessageType = 0x5 MessageTypeBlocks MessageType = 0x6 )
type RPCDecodeFunc ¶
type RPCDecodeFunc func(RPC) (*DecodedMessage, error)
type RPCProcessor ¶
type RPCProcessor interface {
ProcessMessage(*DecodedMessage) error
}
type Server ¶
type Server struct { TCPTransport *TCPTransport ServerOpts // contains filtered or unexported fields }
func NewServer ¶
func NewServer(opts ServerOpts) (*Server, error)
func (*Server) ProcessMessage ¶
func (s *Server) ProcessMessage(msg *DecodedMessage) error
type ServerOpts ¶
type ServerOpts struct { APIListenAddr string SeedNodes []string ListenAddr string TCPTransport *TCPTransport ID string Logger log.Logger RPCDecodeFunc RPCDecodeFunc RPCProcessor RPCProcessor BlockTime time.Duration PrivateKey *crypto.PrivateKey }
type StatusMessage ¶
type TCPTransport ¶
type TCPTransport struct {
// contains filtered or unexported fields
}
func NewTCPTransport ¶
func NewTCPTransport(addr string, peerCh chan *TCPPeer) *TCPTransport
func (*TCPTransport) Start ¶
func (t *TCPTransport) Start() error
type TxPool ¶
type TxPool struct {
// contains filtered or unexported fields
}
func (*TxPool) Add ¶
func (p *TxPool) Add(tx *core.Transaction)
func (*TxPool) ClearPending ¶
func (p *TxPool) ClearPending()
func (*TxPool) Pending ¶
func (p *TxPool) Pending() []*core.Transaction
Pending returns a slice of transactions that are in the pending pool
func (*TxPool) PendingCount ¶
type TxSortedMap ¶
type TxSortedMap struct {
// contains filtered or unexported fields
}
func NewTxSortedMap ¶
func NewTxSortedMap() *TxSortedMap
func (*TxSortedMap) Add ¶
func (t *TxSortedMap) Add(tx *core.Transaction)
func (*TxSortedMap) Clear ¶
func (t *TxSortedMap) Clear()
func (*TxSortedMap) Count ¶
func (t *TxSortedMap) Count() int
func (*TxSortedMap) First ¶
func (t *TxSortedMap) First() *core.Transaction
func (*TxSortedMap) Get ¶
func (t *TxSortedMap) Get(h types.Hash) *core.Transaction
func (*TxSortedMap) Remove ¶
func (t *TxSortedMap) Remove(h types.Hash)
Click to show internal directories.
Click to hide internal directories.