proto

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: May 2, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const OpType_DEBUG = 0x00

Highest bit indicates if it is a reply

View Source
const OpType_PROOFREP = 0x82
View Source
const OpType_PROOFREQ = 0x02

Variables

This section is empty.

Functions

func IsReply

func IsReply(opType OpType) bool

Types

type Length

type Length uint16

type MajorVersion

type MajorVersion uint8

type Message

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

Message represents a message sent between two peers. It can contain multiple Op's Wire Format: 0 - Major Version 1 - Minor Version 2:4 - Message Length, computed by len(m.data) 4:8 - Message ID 8: - Message Data

func NewMessage

func NewMessage() *Message

func ReadFrom

func ReadFrom(in io.Reader) (*Message, error)

func (*Message) GetID

func (m *Message) GetID() MessageID

func (*Message) GetOps

func (m *Message) GetOps() []Op

func (*Message) Pop

func (m *Message) Pop() *Op

func (*Message) Push

func (m *Message) Push(b *Op) error

func (*Message) PushMany

func (m *Message) PushMany(o []*Op) error

func (*Message) WriteTo

func (m *Message) WriteTo(out io.Writer) (int64, error)

type MessageID

type MessageID uint32

type MinorVersion

type MinorVersion uint8

type Op

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

Op represents the op of a single operation. There can be multiple within a single Message Wire Format: 0 - Message Type 1 - Reserved 2:4 - Op Length, computed by len(b.data) 4:8 - Op ID 8: - Op Data

func NewOp

func NewOp(opType OpType, data []byte) (*Op, error)

func (*Op) GetContent

func (op *Op) GetContent() []byte

func (*Op) GetID

func (op *Op) GetID() OpID

func (*Op) GetType

func (op *Op) GetType() OpType

func (*Op) Unmarshal

func (o *Op) Unmarshal() (OpData, error)

type OpData

type OpData interface {
	Marshal() ([]byte, error)
}

func Unmarshal

func Unmarshal(optype OpType, data []byte) (OpData, error)

type OpID

type OpID uint32

type OpType

type OpType uint8

type Op_Debug

type Op_Debug struct {
	Content string `msgpack:"c"`
	OpData
}

func Unmarshal_Debug

func Unmarshal_Debug(data []byte) (*Op_Debug, error)

func (Op_Debug) Marshal

func (o Op_Debug) Marshal() ([]byte, error)

type Op_ProofRep

type Op_ProofRep struct {
	Proof        []byte `msgpack:"p"`
	ReplyingToID OpID   `msgpack:"r"`
	ReplyingOp
}

func Unmarshal_ProofRep

func Unmarshal_ProofRep(data []byte) (*Op_ProofRep, error)

func (Op_ProofRep) GetReplyingTo

func (o Op_ProofRep) GetReplyingTo() OpID

func (Op_ProofRep) Marshal

func (r Op_ProofRep) Marshal() ([]byte, error)

type Op_ProofReq

type Op_ProofReq struct {
	Domain    string            `msgpack:"d"`
	Challenge []byte            `msgpack:"p"`
	HashFunc  crypto.Hash       `msgpack:"h"`
	SigType   netcommon.SigType `msgpack:"s"`
}

func Unmarshal_ProofReq

func Unmarshal_ProofReq(data []byte) (*Op_ProofReq, error)

func (*Op_ProofReq) Marshal

func (o *Op_ProofReq) Marshal() ([]byte, error)

type ProtoServer

type ProtoServer struct {
	Network string
	Laddr   string
	// contains filtered or unexported fields
}

type ReplyingOp

type ReplyingOp interface {
	GetReplyingTo() OpID
}

Jump to

Keyboard shortcuts

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