node

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2018 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LocalNode *node

Functions

func CompareHeight

func CompareHeight(blockHeight uint64, heights []uint64) bool

func GetBlockHashes

func GetBlockHashes(startHash common.Uint256, stopHash common.Uint256, maxBlockHashes uint32) ([]*common.Uint256, error)

func InitLocalNode

func InitLocalNode() protocol.Noder

func NewNode

func NewNode(magic uint32, conn net.Conn) *node

func NewVersion

func NewVersion(node protocol.Noder) *msg.Version

func NonTLSDial

func NonTLSDial(nodeAddr string) (net.Conn, error)

func SendGetBlocks

func SendGetBlocks(node protocol.Noder, locator []*common.Uint256, hashStop common.Uint256)

func TLSDial

func TLSDial(nodeAddr string) (net.Conn, error)

Types

type ConnectingNodes

type ConnectingNodes struct {
	sync.RWMutex
	ConnectingAddrs []string
}

type HandlerBase

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

func NewHandlerBase added in v0.1.1

func NewHandlerBase(node protocol.Noder) *HandlerBase

NewHandlerBase create a new HandlerBase instance

func (*HandlerBase) FilterMessage added in v0.1.1

func (h *HandlerBase) FilterMessage(msgType string) error

Extra net nodes will connect through the specific NodeOpenPort only limited messages can go through, such as filterload/getblocks/getdata etc. Otherwise error will be returned

func (*HandlerBase) HandleMessage added in v0.1.1

func (h *HandlerBase) HandleMessage(message p2p.Message) error

func (*HandlerBase) OnError

func (h *HandlerBase) OnError(err error)

When something wrong on read or decode message this method will callback the error

func (*HandlerBase) OnMakeMessage

func (h *HandlerBase) OnMakeMessage(cmd string) (message p2p.Message, err error)

After message header decoded, this method will be called to create the message instance with the CMD which is the message type of the received message

func (*HandlerBase) OnMessageDecoded

func (h *HandlerBase) OnMessageDecoded(message p2p.Message)

After message has been successful decoded, this method will be called to pass the decoded message instance

type HandlerEIP001

type HandlerEIP001 struct {
	HandlerBase
	// contains filtered or unexported fields
}

func NewHandlerEIP001

func NewHandlerEIP001(node protocol.Noder) *HandlerEIP001

func (*HandlerEIP001) HandleMessage added in v0.1.1

func (h *HandlerEIP001) HandleMessage(message p2p.Message) error

func (*HandlerEIP001) OnMakeMessage

func (h *HandlerEIP001) OnMakeMessage(cmd string) (message p2p.Message, err error)

After message header decoded, this method will be called to create the message instance with the CMD which is the message type of the received message

func (*HandlerEIP001) OnMessageDecoded

func (h *HandlerEIP001) OnMessageDecoded(message p2p.Message)

After message has been successful decoded, this method will be called to pass the decoded message instance

type HandlerV0

type HandlerV0 struct {
	HandlerBase
	// contains filtered or unexported fields
}

func NewHandlerV0

func NewHandlerV0(node protocol.Noder) *HandlerV0

func (*HandlerV0) HandleMessage added in v0.1.1

func (h *HandlerV0) HandleMessage(message p2p.Message) error

After message has been successful decoded, this method will be called to pass the decoded message instance

func (*HandlerV0) OnMakeMessage

func (h *HandlerV0) OnMakeMessage(cmd string) (message p2p.Message, err error)

After message header decoded, this method will be called to create the message instance with the CMD which is the message type of the received message

func (*HandlerV0) OnMessageDecoded

func (h *HandlerV0) OnMessageDecoded(message p2p.Message)

type KnownAddress

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

func (*KnownAddress) GetID

func (ka *KnownAddress) GetID() uint64

func (*KnownAddress) LastAttempt

func (ka *KnownAddress) LastAttempt() time.Time

func (*KnownAddress) NetAddress

func (ka *KnownAddress) NetAddress() p2p.NetAddress

func (*KnownAddress) SaveAddr

func (ka *KnownAddress) SaveAddr(na p2p.NetAddress)

type KnownAddressList

type KnownAddressList struct {
	sync.RWMutex
	List map[uint64]*KnownAddress
	// contains filtered or unexported fields
}

func (*KnownAddressList) AddKnownAddress

func (al *KnownAddressList) AddKnownAddress(na p2p.NetAddress)

func (*KnownAddressList) AddressExisted

func (al *KnownAddressList) AddressExisted(uid uint64) bool

func (*KnownAddressList) DelAddressFromList

func (al *KnownAddressList) DelAddressFromList(id uint64) bool

func (*KnownAddressList) GetAddressCnt

func (al *KnownAddressList) GetAddressCnt() uint64

func (*KnownAddressList) NeedMoreAddresses

func (al *KnownAddressList) NeedMoreAddresses() bool

func (*KnownAddressList) RandGetAddresses

func (al *KnownAddressList) RandGetAddresses(nbrAddrs []p2p.NetAddress) []p2p.NetAddress

func (*KnownAddressList) RandSelectAddresses

func (al *KnownAddressList) RandSelectAddresses() []p2p.NetAddress

func (*KnownAddressList) UpdateAddress

func (al *KnownAddressList) UpdateAddress(id uint64, na p2p.NetAddress)

func (*KnownAddressList) UpdateLastDisconn

func (al *KnownAddressList) UpdateLastDisconn(id uint64)

type Semaphore

type Semaphore chan struct{}

func MakeSemaphore

func MakeSemaphore(n int) Semaphore

Jump to

Keyboard shortcuts

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