protocol

package
v0.0.0-...-cf6e08f Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2018 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	C_TX        = "tx"
	C_INV       = "inv"
	C_PING      = "ping"
	C_PONG      = "pong"
	C_ADDR      = "addr"
	C_BLOCK     = "block"
	C_ERROR     = "error"
	C_VERSION   = "version"
	C_GETDATA   = "getdata"
	C_GETBLOCKS = "getblocks"
	C_MESSAGE   = "msg"
	C_SYNCED    = "synced"
)
View Source
const (
	PROTOCOL       = "tcp"
	NODE_VERSION   = 1
	COMMAND_LENGTH = 12
)

Variables

This section is empty.

Functions

func BytesToCommand

func BytesToCommand(bytes []byte) string

func CommandToBytes

func CommandToBytes(command string) []byte

func ExtractCommand

func ExtractCommand(request []byte) []byte

func GobEncode

func GobEncode(data interface{}) []byte

func MakeRequest

func MakeRequest(data interface{}, cmd string) []byte

Types

type Configuration

type Configuration struct {
	Chain *core.BlockChain
	Nodes *map[string]bool
}
type Header struct {
}

type Protocol

type Protocol struct {
	Config *Configuration
}

func (*Protocol) HandleAddr

func (*Protocol) HandleAddr(request []byte)

func (*Protocol) HandleBlock

func (p *Protocol) HandleBlock(request []byte)

func (*Protocol) HandleError

func (*Protocol) HandleError(request []byte)

func (*Protocol) HandleGetBlocks

func (p *Protocol) HandleGetBlocks(request []byte)

func (*Protocol) HandleGetData

func (p *Protocol) HandleGetData(request []byte)

func (*Protocol) HandleInv

func (p *Protocol) HandleInv(request []byte)

func (*Protocol) HandleMessage

func (*Protocol) HandleMessage(request []byte)

func (*Protocol) HandlePing

func (p *Protocol) HandlePing(request []byte) bool

func (*Protocol) HandlePong

func (*Protocol) HandlePong(request []byte)

func (*Protocol) HandleTx

func (p *Protocol) HandleTx(request []byte)

func (*Protocol) HandleVersion

func (p *Protocol) HandleVersion(request []byte)

func (*Protocol) SendAddr

func (p *Protocol) SendAddr(addrTo string) bool

func (*Protocol) SendBlock

func (p *Protocol) SendBlock(addrFrom, addrTo string, newBlock types.Block) bool

func (*Protocol) SendGetBlocks

func (p *Protocol) SendGetBlocks(addrFrom, addrTo string) bool

func (*Protocol) SendGetData

func (p *Protocol) SendGetData(addrFrom, addrTo, kind string, id []byte) bool

func (*Protocol) SendInv

func (p *Protocol) SendInv(addrFrom, addrTo, kind string, items [][]byte) bool

func (*Protocol) SendMessage

func (p *Protocol) SendMessage(addrTo, msgType string) bool

func (*Protocol) SendPing

func (p *Protocol) SendPing(addrFrom, addrTo string) bool

func (*Protocol) SendPong

func (p *Protocol) SendPong(addrFrom, addrTo string) bool

func (*Protocol) SendTx

func (p *Protocol) SendTx(addrFrom, addrTo string, tnx types.Transaction) bool

func (*Protocol) SendVersion

func (p *Protocol) SendVersion(addrFrom, addrTo string) bool

Jump to

Keyboard shortcuts

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