node

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2019 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DumpNodeStateInterval = time.Minute * 5
	NodeTitleFormat       = "| %-5s | %-16s | %-8s | %-16s | %-5s | %5s | %5s | %5s | %5s | %13s |\n"
	NodeLineFormat        = "| %-5d | %-16x | %-8d | %-16d | %-5t | %5d | %5d | %5d | %5d | %13s |\n"
	NeighborTitleFormat   = "| %-5s | %-16s | %-8s | %-16s | %-5s | %-5s | %-11s | %23s |\n"
	NeighborLineFormat    = "| %-5d | %-16x | %-8d | %-16d | %-5t | %-5t | %-11s | %23s |\n"
)

Variables

View Source
var LocalNode *node

Functions

func CompareHeight

func CompareHeight(localHeight uint64, heights []uint64) int

func DisconnectNode added in v0.2.1

func DisconnectNode(id uint64)

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(conn net.Conn, inbound bool) *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
	List map[string]struct{}
}

type HandlerBase

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

func NewHandlerBase added in v0.2.0

func NewHandlerBase(node protocol.Noder) *HandlerBase

NewHandlerBase create a new HandlerBase instance

func (*HandlerBase) FilterMessage added in v0.2.0

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

External 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.2.0

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

func (*HandlerBase) MakeEmptyMessage added in v0.2.1

func (h *HandlerBase) MakeEmptyMessage(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

type HandlerEIP001

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

func NewHandlerEIP001

func NewHandlerEIP001(node protocol.Noder) *HandlerEIP001

func (*HandlerEIP001) HandleMessage added in v0.2.0

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

func (*HandlerEIP001) MakeEmptyMessage added in v0.2.1

func (h *HandlerEIP001) MakeEmptyMessage(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

type HandlerV0

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

func NewHandlerV0

func NewHandlerV0(node protocol.Noder) *HandlerV0

func (*HandlerV0) HandleMessage added in v0.2.0

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

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

func (*HandlerV0) MakeEmptyMessage added in v0.2.1

func (h *HandlerV0) MakeEmptyMessage(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

type KnownAddress

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

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[string]*KnownAddress
	// contains filtered or unexported fields
}

func (*KnownAddressList) AddKnownAddress

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

func (*KnownAddressList) GetAddressCnt

func (al *KnownAddressList) GetAddressCnt() uint64

func (*KnownAddressList) NeedMoreAddresses

func (al *KnownAddressList) NeedMoreAddresses() bool

func (*KnownAddressList) RandGetAddresses

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

func (*KnownAddressList) RandSelectAddresses

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

func (*KnownAddressList) UpdateAddress

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

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