wire

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: May 20, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Envelope

type Envelope struct {
	Magic       uint32
	MessageType MessageType
	Timestamp   time.Time
	Message     Message
	Signature   crypto.Signature
}

func NewEnvelope

func NewEnvelope(magic uint32, message Message, signer crypto.Signer) (*Envelope, error)

func (*Envelope) Decode

func (e *Envelope) Decode(r io.Reader) error

func (*Envelope) Encode

func (e *Envelope) Encode(w io.Writer) error

func (*Envelope) Equals

func (e *Envelope) Equals(other *Envelope) bool

func (*Envelope) Hash

func (e *Envelope) Hash() (crypto.Hash, error)

type HashCacher

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

func (*HashCacher) Hash

func (h *HashCacher) Hash(enc dwire.Encoder) (crypto.Hash, error)

type Hello

type Hello struct {
	HashCacher

	ProtocolVersion uint32
	LocalNonce      [32]byte
	RemoteNonce     [32]byte
	PublicKey       *btcec.PublicKey
	UserAgent       string
}

func (*Hello) Decode

func (h *Hello) Decode(r io.Reader) error

func (*Hello) Encode

func (h *Hello) Encode(w io.Writer) error

func (*Hello) Equals

func (h *Hello) Equals(other Message) bool

func (*Hello) Hash

func (h *Hello) Hash() (crypto.Hash, error)

func (*Hello) MsgType

func (h *Hello) MsgType() MessageType

type HelloAck

type HelloAck struct {
	HashCacher

	Nonce [32]byte
}

func (*HelloAck) Decode

func (h *HelloAck) Decode(r io.Reader) error

func (*HelloAck) Encode

func (h *HelloAck) Encode(w io.Writer) error

func (*HelloAck) Equals

func (h *HelloAck) Equals(other Message) bool

func (*HelloAck) Hash

func (h *HelloAck) Hash() (crypto.Hash, error)

func (*HelloAck) MsgType

func (h *HelloAck) MsgType() MessageType

type IPEncoder

type IPEncoder net.IP

func (*IPEncoder) Decode

func (i *IPEncoder) Decode(r io.Reader) error

func (IPEncoder) Encode

func (i IPEncoder) Encode(w io.Writer) error

type Message

type Message interface {
	crypto.Hasher
	dwire.EncodeDecoder
	MsgType() MessageType
	Equals(other Message) bool
}

type MessageType

type MessageType uint16
const (
	MessageTypeHello MessageType = iota
	MessageTypeHelloAck
	MessageTypePing
	MessageTypeUpdate
	MessageTypeNilUpdate
	MessageTypeTreeBaseReq
	MessageTypeTreeBaseRes
	MessageTypeSectorReq
	MessageTypeSectorRes
	MessageTypePeerReq
	MessageTypePeerRes
	MessageTypeUpdateReq
	MessageTypeNameRes
)

func (*MessageType) Decode

func (t *MessageType) Decode(r io.Reader) error

func (MessageType) Encode

func (t MessageType) Encode(w io.Writer) error

func (MessageType) String

func (t MessageType) String() string

type NilUpdate

type NilUpdate struct {
	HashCacher

	Name string
	// contains filtered or unexported fields
}

func NewNilUpdate

func NewNilUpdate(name string) *NilUpdate

func (*NilUpdate) Decode

func (n *NilUpdate) Decode(r io.Reader) error

func (*NilUpdate) Encode

func (n *NilUpdate) Encode(w io.Writer) error

func (*NilUpdate) Equals

func (n *NilUpdate) Equals(other Message) bool

func (*NilUpdate) Hash

func (n *NilUpdate) Hash() (crypto.Hash, error)

func (*NilUpdate) MsgType

func (n *NilUpdate) MsgType() MessageType

type Peer

type Peer struct {
	IP net.IP
	ID crypto.Hash
}

func (*Peer) Decode

func (p *Peer) Decode(r io.Reader) error

func (*Peer) Encode

func (p *Peer) Encode(w io.Writer) error

type PeerReq

type PeerReq struct {
	HashCacher
}

func (*PeerReq) Decode

func (p *PeerReq) Decode(r io.Reader) error

func (*PeerReq) Encode

func (p *PeerReq) Encode(w io.Writer) error

func (*PeerReq) Equals

func (p *PeerReq) Equals(other Message) bool

func (*PeerReq) Hash

func (p *PeerReq) Hash() (crypto.Hash, error)

func (*PeerReq) MsgType

func (p *PeerReq) MsgType() MessageType

type PeerRes

type PeerRes struct {
	HashCacher

	Peers []*Peer
}

func (*PeerRes) Decode

func (p *PeerRes) Decode(r io.Reader) error

func (*PeerRes) Encode

func (p *PeerRes) Encode(w io.Writer) error

func (*PeerRes) Equals

func (p *PeerRes) Equals(other Message) bool

func (*PeerRes) Hash

func (p *PeerRes) Hash() (crypto.Hash, error)

func (*PeerRes) MsgType

func (p *PeerRes) MsgType() MessageType

type Ping

type Ping struct {
	HashCacher
}

func NewPing

func NewPing() *Ping

func (*Ping) Decode

func (p *Ping) Decode(r io.Reader) error

func (*Ping) Encode

func (p *Ping) Encode(w io.Writer) error

func (*Ping) Equals

func (p *Ping) Equals(other Message) bool

func (*Ping) Hash

func (p *Ping) Hash() (crypto.Hash, error)

func (*Ping) MsgType

func (p *Ping) MsgType() MessageType

type PublicKeyEncoder

type PublicKeyEncoder struct {
	PublicKey *btcec.PublicKey
}

func (*PublicKeyEncoder) Decode

func (p *PublicKeyEncoder) Decode(r io.Reader) error

func (*PublicKeyEncoder) Encode

func (p *PublicKeyEncoder) Encode(w io.Writer) error

type SectorReq

type SectorReq struct {
	HashCacher

	Name     string
	SectorID uint8
}

func (*SectorReq) Decode

func (s *SectorReq) Decode(r io.Reader) error

func (*SectorReq) Encode

func (s *SectorReq) Encode(w io.Writer) error

func (*SectorReq) Equals

func (s *SectorReq) Equals(other Message) bool

func (*SectorReq) Hash

func (s *SectorReq) Hash() (crypto.Hash, error)

func (*SectorReq) MsgType

func (s *SectorReq) MsgType() MessageType

type SectorRes

type SectorRes struct {
	HashCacher

	Name     string
	SectorID uint8
	Sector   blob.Sector
}

func (*SectorRes) Decode

func (s *SectorRes) Decode(r io.Reader) error

func (*SectorRes) Encode

func (s *SectorRes) Encode(w io.Writer) error

func (*SectorRes) Equals

func (s *SectorRes) Equals(other Message) bool

func (*SectorRes) Hash

func (s *SectorRes) Hash() (crypto.Hash, error)

func (*SectorRes) MsgType

func (s *SectorRes) MsgType() MessageType

type TreeBaseReq

type TreeBaseReq struct {
	HashCacher

	Name string
}

func (*TreeBaseReq) Decode

func (d *TreeBaseReq) Decode(r io.Reader) error

func (*TreeBaseReq) Encode

func (d *TreeBaseReq) Encode(w io.Writer) error

func (*TreeBaseReq) Equals

func (d *TreeBaseReq) Equals(other Message) bool

func (*TreeBaseReq) Hash

func (d *TreeBaseReq) Hash() (crypto.Hash, error)

func (*TreeBaseReq) MsgType

func (d *TreeBaseReq) MsgType() MessageType

type TreeBaseRes

type TreeBaseRes struct {
	HashCacher

	Name       string
	MerkleBase blob.MerkleBase
}

func (*TreeBaseRes) Decode

func (d *TreeBaseRes) Decode(r io.Reader) error

func (*TreeBaseRes) Encode

func (d *TreeBaseRes) Encode(w io.Writer) error

func (*TreeBaseRes) Equals

func (d *TreeBaseRes) Equals(other Message) bool

func (*TreeBaseRes) Hash

func (d *TreeBaseRes) Hash() (crypto.Hash, error)

func (*TreeBaseRes) MsgType

func (d *TreeBaseRes) MsgType() MessageType

type Update

type Update struct {
	HashCacher

	Name         string
	Timestamp    time.Time
	MerkleRoot   crypto.Hash
	ReservedRoot crypto.Hash
	Signature    crypto.Signature
}

func (*Update) Decode

func (u *Update) Decode(r io.Reader) error

func (*Update) Encode

func (u *Update) Encode(w io.Writer) error

func (*Update) Equals

func (u *Update) Equals(other Message) bool

func (*Update) Hash

func (u *Update) Hash() (crypto.Hash, error)

func (*Update) MsgType

func (u *Update) MsgType() MessageType

type UpdateReq

type UpdateReq struct {
	HashCacher

	Name      string
	Timestamp time.Time
}

func (*UpdateReq) Decode

func (n *UpdateReq) Decode(r io.Reader) error

func (*UpdateReq) Encode

func (n *UpdateReq) Encode(w io.Writer) error

func (*UpdateReq) Equals

func (n *UpdateReq) Equals(other Message) bool

func (*UpdateReq) Hash

func (n *UpdateReq) Hash() (crypto.Hash, error)

func (*UpdateReq) MsgType

func (n *UpdateReq) MsgType() MessageType

Jump to

Keyboard shortcuts

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