msg

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxLength = 5000000
	MaxAddrs  = 100
	MaxInv    = 1000
	MaxTx     = 1000
)

Maxs for messages.

View Source
const MessageVersion = 1

MessageVersion is a version of the message.

View Source
const (
	ServiceFull byte = iota
)

Services in Version mesasge.

Variables

View Source
var (
	ErrInvalidLengthMsg = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowMsg   = fmt.Errorf("proto: integer overflow")
)
View Source
var (

	//ConnectionTimeout is the priod of sending ping.
	ConnectionTimeout = 10 * time.Minute
)

Functions

func TxType2DBHeader

func TxType2DBHeader(typ tx.Type) (db.Header, error)

TxType2DBHeader return db beader from tx type.

func Write

func Write(s *setting.Setting, m proto.Marshaler, cmd Command, conn io.Writer) error

Write write a message to con.

Types

type Addr

type Addr struct {
	Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
	Service byte   `protobuf:"varint,2,opt,name=service,proto3,casttype=byte" json:"service,omitempty"`
}

Addr is an IP address and port.

func NewAddr

func NewAddr(adr string, service byte) *Addr

NewAddr returns a Addr struct.

func NewPopulatedAddr

func NewPopulatedAddr(r randyMsg, easy bool) *Addr

func (*Addr) Descriptor

func (*Addr) Descriptor() ([]byte, []int)

func (*Addr) Equal

func (this *Addr) Equal(that interface{}) bool

func (*Addr) Marshal

func (m *Addr) Marshal() (dAtA []byte, err error)

func (*Addr) MarshalTo

func (m *Addr) MarshalTo(dAtA []byte) (int, error)

func (*Addr) ProtoMessage

func (*Addr) ProtoMessage()

func (*Addr) Reset

func (m *Addr) Reset()

func (*Addr) Size

func (m *Addr) Size() (n int)

func (*Addr) String

func (m *Addr) String() string

func (*Addr) Unmarshal

func (m *Addr) Unmarshal(dAtA []byte) error

func (*Addr) XXX_DiscardUnknown

func (m *Addr) XXX_DiscardUnknown()

func (*Addr) XXX_Marshal

func (m *Addr) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Addr) XXX_Merge

func (dst *Addr) XXX_Merge(src proto.Message)

func (*Addr) XXX_Size

func (m *Addr) XXX_Size() int

func (*Addr) XXX_Unmarshal

func (m *Addr) XXX_Unmarshal(b []byte) error

type Addrs

type Addrs []*Addr

Addrs provides information on known nodes of the network.

func ReadAddrs

func ReadAddrs(s *setting.Setting, buf []byte) (Addrs, error)

ReadAddrs read and make a Addrs struct.

type AddrsProto

type AddrsProto struct {
	Addrs []*Addr `protobuf:"bytes,1,rep,name=addrs,proto3" json:"addrs,omitempty"`
}

func NewPopulatedAddrsProto

func NewPopulatedAddrsProto(r randyMsg, easy bool) *AddrsProto

func (*AddrsProto) Descriptor

func (*AddrsProto) Descriptor() ([]byte, []int)

func (*AddrsProto) Equal

func (this *AddrsProto) Equal(that interface{}) bool

func (*AddrsProto) Marshal

func (m *AddrsProto) Marshal() (dAtA []byte, err error)

func (*AddrsProto) MarshalTo

func (m *AddrsProto) MarshalTo(dAtA []byte) (int, error)

func (*AddrsProto) ProtoMessage

func (*AddrsProto) ProtoMessage()

func (*AddrsProto) Reset

func (m *AddrsProto) Reset()

func (*AddrsProto) Size

func (m *AddrsProto) Size() (n int)

func (*AddrsProto) String

func (m *AddrsProto) String() string

func (*AddrsProto) Unmarshal

func (m *AddrsProto) Unmarshal(dAtA []byte) error

func (*AddrsProto) XXX_DiscardUnknown

func (m *AddrsProto) XXX_DiscardUnknown()

func (*AddrsProto) XXX_Marshal

func (m *AddrsProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*AddrsProto) XXX_Merge

func (dst *AddrsProto) XXX_Merge(src proto.Message)

func (*AddrsProto) XXX_Size

func (m *AddrsProto) XXX_Size() int

func (*AddrsProto) XXX_Unmarshal

func (m *AddrsProto) XXX_Unmarshal(b []byte) error

type Command

type Command byte

Command is a command byte

const (
	CmdVersion   Command = iota + 1 //Header + Version  p2p 1
	CmdVerack                       // Header  p2p 2
	CmdPing                         // Header + Nonce ,p2p 3
	CmdPong                         // Header+ Nonce,p2p 4
	CmdGetAddr                      // Header,p2p 5
	CmdAddr                         // Header * Addrs,p2p 6
	CmdInv                          // Header + Inventories,broadcast 7
	CmdGetData                      // Header+ Inventories,p2p 8
	CmdTxs                          // Header+ Txs,p2p 9
	CmdClose                        //Header,p2p 12
	CmdGetLeaves                    // Header + LeavesFrom,p2p 10
	CmdLeaves                       // Header + Inventories,p2p 11
	CmdFollowingHash
	CmdGetFollowingHash
	CmdConsensusMessage //15
)

Commands in Header.

func ReadHeader

func ReadHeader(s *setting.Setting, conn io.Reader) (Command, []byte, error)

ReadHeader read a message from con and returns msg type.

func (Command) String

func (c Command) String() string

type Hashes

type Hashes struct {
	Hashes []github_com_AidosKuneen_aklib_tx.Hash `protobuf:"bytes,1,rep,name=hashes,proto3,casttype=github.com/AidosKuneen/aklib/tx.Hash" json:"hashes,omitempty"`
}

func NewPopulatedHashes

func NewPopulatedHashes(r randyMsg, easy bool) *Hashes

func (*Hashes) Descriptor

func (*Hashes) Descriptor() ([]byte, []int)

func (*Hashes) Equal

func (this *Hashes) Equal(that interface{}) bool

func (*Hashes) Marshal

func (m *Hashes) Marshal() (dAtA []byte, err error)

func (*Hashes) MarshalTo

func (m *Hashes) MarshalTo(dAtA []byte) (int, error)

func (*Hashes) ProtoMessage

func (*Hashes) ProtoMessage()

func (*Hashes) Reset

func (m *Hashes) Reset()

func (*Hashes) Size

func (m *Hashes) Size() (n int)

func (*Hashes) String

func (m *Hashes) String() string

func (*Hashes) Unmarshal

func (m *Hashes) Unmarshal(dAtA []byte) error

func (*Hashes) XXX_DiscardUnknown

func (m *Hashes) XXX_DiscardUnknown()

func (*Hashes) XXX_Marshal

func (m *Hashes) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Hashes) XXX_Merge

func (dst *Hashes) XXX_Merge(src proto.Message)

func (*Hashes) XXX_Size

func (m *Hashes) XXX_Size() int

func (*Hashes) XXX_Unmarshal

func (m *Hashes) XXX_Unmarshal(b []byte) error

type InvType

type InvType byte

InvType is a tx type of Inv.

const (
	InvTxNormal InvType = iota
	InvTxRewardTicket
	InvTxRewardFee
)

Invenory types

func TxType2InvType

func TxType2InvType(typ tx.Type) (InvType, error)

TxType2InvType return inventory type from tx type.

func (InvType) ToTxType

func (it InvType) ToTxType() (tx.Type, error)

ToTxType return a tx type from inventory type.

type Inventories

type Inventories []*Inventory

Inventories is a slice of Inventory, for inv, getdata, notfound messages.

func ReadInventories

func ReadInventories(buf []byte) (Inventories, error)

ReadInventories read and make a Inventories struct.

type InventoriesProto

type InventoriesProto struct {
	Inventories []*Inventory `protobuf:"bytes,1,rep,name=inventories,proto3" json:"inventories,omitempty"`
}

func NewPopulatedInventoriesProto

func NewPopulatedInventoriesProto(r randyMsg, easy bool) *InventoriesProto

func (*InventoriesProto) Descriptor

func (*InventoriesProto) Descriptor() ([]byte, []int)

func (*InventoriesProto) Equal

func (this *InventoriesProto) Equal(that interface{}) bool

func (*InventoriesProto) Marshal

func (m *InventoriesProto) Marshal() (dAtA []byte, err error)

func (*InventoriesProto) MarshalTo

func (m *InventoriesProto) MarshalTo(dAtA []byte) (int, error)

func (*InventoriesProto) ProtoMessage

func (*InventoriesProto) ProtoMessage()

func (*InventoriesProto) Reset

func (m *InventoriesProto) Reset()

func (*InventoriesProto) Size

func (m *InventoriesProto) Size() (n int)

func (*InventoriesProto) String

func (m *InventoriesProto) String() string

func (*InventoriesProto) Unmarshal

func (m *InventoriesProto) Unmarshal(dAtA []byte) error

func (*InventoriesProto) XXX_DiscardUnknown

func (m *InventoriesProto) XXX_DiscardUnknown()

func (*InventoriesProto) XXX_Marshal

func (m *InventoriesProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*InventoriesProto) XXX_Merge

func (dst *InventoriesProto) XXX_Merge(src proto.Message)

func (*InventoriesProto) XXX_Size

func (m *InventoriesProto) XXX_Size() int

func (*InventoriesProto) XXX_Unmarshal

func (m *InventoriesProto) XXX_Unmarshal(b []byte) error

type Inventory

type Inventory struct {
	Type InvType `protobuf:"varint,1,opt,name=type,proto3,casttype=InvType" json:"type,omitempty"`
	Hash []byte  `protobuf:"bytes,2,opt,name=hash,proto3" json:"hash,omitempty"`
}

Inventory vectors are used for notifying other nodes about objects they have or data which is being requested.

func NewPopulatedInventory

func NewPopulatedInventory(r randyMsg, easy bool) *Inventory

func (*Inventory) Descriptor

func (*Inventory) Descriptor() ([]byte, []int)

func (*Inventory) Equal

func (this *Inventory) Equal(that interface{}) bool

func (*Inventory) Marshal

func (m *Inventory) Marshal() (dAtA []byte, err error)

func (*Inventory) MarshalTo

func (m *Inventory) MarshalTo(dAtA []byte) (int, error)

func (*Inventory) ProtoMessage

func (*Inventory) ProtoMessage()

func (*Inventory) Reset

func (m *Inventory) Reset()

func (*Inventory) Size

func (m *Inventory) Size() (n int)

func (*Inventory) String

func (m *Inventory) String() string

func (*Inventory) Unmarshal

func (m *Inventory) Unmarshal(dAtA []byte) error

func (*Inventory) XXX_DiscardUnknown

func (m *Inventory) XXX_DiscardUnknown()

func (*Inventory) XXX_Marshal

func (m *Inventory) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Inventory) XXX_Merge

func (dst *Inventory) XXX_Merge(src proto.Message)

func (*Inventory) XXX_Size

func (m *Inventory) XXX_Size() int

func (*Inventory) XXX_Unmarshal

func (m *Inventory) XXX_Unmarshal(b []byte) error

type Nonce

type Nonce [32]byte

Nonce is a nonce for ping and pong.

func ReadNonce

func ReadNonce(buf []byte) (*Nonce, error)

ReadNonce read and make a Nonce struct.

type NonceProto

type NonceProto struct {
	Nonce []byte `protobuf:"bytes,1,opt,name=nonce,proto3" json:"nonce,omitempty"`
}

func NewPopulatedNonceProto

func NewPopulatedNonceProto(r randyMsg, easy bool) *NonceProto

func (*NonceProto) Descriptor

func (*NonceProto) Descriptor() ([]byte, []int)

func (*NonceProto) Equal

func (this *NonceProto) Equal(that interface{}) bool

func (*NonceProto) Marshal

func (m *NonceProto) Marshal() (dAtA []byte, err error)

func (*NonceProto) MarshalTo

func (m *NonceProto) MarshalTo(dAtA []byte) (int, error)

func (*NonceProto) ProtoMessage

func (*NonceProto) ProtoMessage()

func (*NonceProto) Reset

func (m *NonceProto) Reset()

func (*NonceProto) Size

func (m *NonceProto) Size() (n int)

func (*NonceProto) String

func (m *NonceProto) String() string

func (*NonceProto) Unmarshal

func (m *NonceProto) Unmarshal(dAtA []byte) error

func (*NonceProto) XXX_DiscardUnknown

func (m *NonceProto) XXX_DiscardUnknown()

func (*NonceProto) XXX_Marshal

func (m *NonceProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*NonceProto) XXX_Merge

func (dst *NonceProto) XXX_Merge(src proto.Message)

func (*NonceProto) XXX_Size

func (m *NonceProto) XXX_Size() int

func (*NonceProto) XXX_Unmarshal

func (m *NonceProto) XXX_Unmarshal(b []byte) error

type Tx

type Tx struct {
	Type InvType         `protobuf:"varint,1,opt,name=type,proto3,casttype=InvType" json:"type,omitempty"`
	Tx   *tx.Transaction `protobuf:"bytes,2,opt,name=tx,proto3" json:"tx,omitempty"`
}

Tx describes a transaction with Invenroty type.

func NewPopulatedTx

func NewPopulatedTx(r randyMsg, easy bool) *Tx

func (*Tx) Descriptor

func (*Tx) Descriptor() ([]byte, []int)

func (*Tx) Equal

func (this *Tx) Equal(that interface{}) bool

func (*Tx) Marshal

func (m *Tx) Marshal() (dAtA []byte, err error)

func (*Tx) MarshalTo

func (m *Tx) MarshalTo(dAtA []byte) (int, error)

func (*Tx) ProtoMessage

func (*Tx) ProtoMessage()

func (*Tx) Reset

func (m *Tx) Reset()

func (*Tx) Size

func (m *Tx) Size() (n int)

func (*Tx) String

func (m *Tx) String() string

func (*Tx) Unmarshal

func (m *Tx) Unmarshal(dAtA []byte) error

func (*Tx) XXX_DiscardUnknown

func (m *Tx) XXX_DiscardUnknown()

func (*Tx) XXX_Marshal

func (m *Tx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Tx) XXX_Merge

func (dst *Tx) XXX_Merge(src proto.Message)

func (*Tx) XXX_Size

func (m *Tx) XXX_Size() int

func (*Tx) XXX_Unmarshal

func (m *Tx) XXX_Unmarshal(b []byte) error

type Txs

type Txs []*Tx

Txs describes a transaction slice in reply to getTxs

func ReadTxs

func ReadTxs(buf []byte) (Txs, error)

ReadTxs read and make a Txs struct.

type TxsProto

type TxsProto struct {
	Txs []*Tx `protobuf:"bytes,1,rep,name=txs,proto3" json:"txs,omitempty"`
}

func NewPopulatedTxsProto

func NewPopulatedTxsProto(r randyMsg, easy bool) *TxsProto

func (*TxsProto) Descriptor

func (*TxsProto) Descriptor() ([]byte, []int)

func (*TxsProto) Equal

func (this *TxsProto) Equal(that interface{}) bool

func (*TxsProto) Marshal

func (m *TxsProto) Marshal() (dAtA []byte, err error)

func (*TxsProto) MarshalTo

func (m *TxsProto) MarshalTo(dAtA []byte) (int, error)

func (*TxsProto) ProtoMessage

func (*TxsProto) ProtoMessage()

func (*TxsProto) Reset

func (m *TxsProto) Reset()

func (*TxsProto) Size

func (m *TxsProto) Size() (n int)

func (*TxsProto) String

func (m *TxsProto) String() string

func (*TxsProto) Unmarshal

func (m *TxsProto) Unmarshal(dAtA []byte) error

func (*TxsProto) XXX_DiscardUnknown

func (m *TxsProto) XXX_DiscardUnknown()

func (*TxsProto) XXX_Marshal

func (m *TxsProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TxsProto) XXX_Merge

func (dst *TxsProto) XXX_Merge(src proto.Message)

func (*TxsProto) XXX_Size

func (m *TxsProto) XXX_Size() int

func (*TxsProto) XXX_Unmarshal

func (m *TxsProto) XXX_Unmarshal(b []byte) error

type Version

type Version struct {
	Version   uint16 `protobuf:"varint,1,opt,name=version,proto3,casttype=uint16" json:"version,omitempty"`
	Nonce     uint64 `protobuf:"varint,2,opt,name=nonce,proto3" json:"nonce,omitempty"`
	AddrFrom  Addr   `protobuf:"bytes,3,opt,name=addr_from,json=addrFrom,proto3" json:"addr_from"`
	AddrTo    Addr   `protobuf:"bytes,4,opt,name=addr_to,json=addrTo,proto3" json:"addr_to"`
	UserAgent string `protobuf:"bytes,5,opt,name=user_agent,json=userAgent,proto3" json:"user_agent,omitempty"`
}

Version is a message when a node creates an outgoing connection.

func NewPopulatedVersion

func NewPopulatedVersion(r randyMsg, easy bool) *Version

func NewVersion

func NewVersion(s *setting.Setting, to Addr, nonce uint64) *Version

NewVersion returns Verstion struct.

func ReadVersion

func ReadVersion(s *setting.Setting, buf []byte, verNonce uint64) (*Version, error)

ReadVersion read and make a Version struct.

func (*Version) Descriptor

func (*Version) Descriptor() ([]byte, []int)

func (*Version) Equal

func (this *Version) Equal(that interface{}) bool

func (*Version) Marshal

func (m *Version) Marshal() (dAtA []byte, err error)

func (*Version) MarshalTo

func (m *Version) MarshalTo(dAtA []byte) (int, error)

func (*Version) ProtoMessage

func (*Version) ProtoMessage()

func (*Version) Reset

func (m *Version) Reset()

func (*Version) Size

func (m *Version) Size() (n int)

func (*Version) String

func (m *Version) String() string

func (*Version) Unmarshal

func (m *Version) Unmarshal(dAtA []byte) error

func (*Version) XXX_DiscardUnknown

func (m *Version) XXX_DiscardUnknown()

func (*Version) XXX_Marshal

func (m *Version) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Version) XXX_Merge

func (dst *Version) XXX_Merge(src proto.Message)

func (*Version) XXX_Size

func (m *Version) XXX_Size() int

func (*Version) XXX_Unmarshal

func (m *Version) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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