p2p

package
v0.0.0-...-0764be2 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleConnection

func HandleConnection(conn net.Conn, bc *core.Blockchain)

func SendCmd

func SendCmd(address string, payload []byte) error

func StartServer

func StartServer() error

Types

type Address

type Address struct {
	Address   NetAddress
	Handshake bool
	Timestamp int64
}

type GetBlocks

type GetBlocks struct {
	Height int32  // Height of the latest block you have
	Hash   []byte // Hash of the last block you have
}

type GetData

type GetData struct {
	Height int32
	Hash   []byte
	Kind   string
}

type Inventory

type Inventory struct {
	Height []int32  // Height is the height of the block that the item is at
	Items  [][]byte // Items are a list of hashes. Transaction or block hashes
	Kind   string   // Kind tells the node whether this is for transactions or for blocks
}

type NetAddress

type NetAddress struct {
	IP   net.IP
	Port int
}

func (*NetAddress) SetPort

func (addr *NetAddress) SetPort()

SetPort sets the port of an address. Default is nodePort. If the address is known tho, make the port the actual port of the address. Usually all ports are the same.

func (NetAddress) String

func (addr NetAddress) String() string

String converts a full netAddress to string

type Version

type Version struct {
	Version     int32      // 4 bytes // version of the node
	Timestamp   int64      // 8 bytes // timestamp of when this version message is being sent
	AddrRecv    NetAddress // eventually make this 26 bytes // address of where this is being sent
	AddrFrom    NetAddress // address to whom this came from
	BlockHeight int32      // current height of the blockchain on the node
}

Jump to

Keyboard shortcuts

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