Documentation ¶
Overview ¶
Package proto provides an implementation of the Nano network protocol.
Index ¶
- Constants
- Variables
- func Name(id byte) string
- type BlockPacket
- type BulkPullBlocksPacket
- type BulkPullMode
- type BulkPullPacket
- type ConfirmAckPacket
- type ConfirmReqPacket
- type FrontierReqPacket
- type HandshakePacket
- type Header
- type KeepAlivePacket
- type Network
- type Packet
- type Proto
- type PublishPacket
- type Versions
- type VotePacket
Constants ¶
const ( NetworkTest = 'Y' NetworkBeta = 'Z' NetworkLive = 'X' )
const (
HeaderSize = 8
)
Variables ¶
Functions ¶
Types ¶
type BlockPacket ¶
func (BlockPacket) MarshalBinary ¶
func (s BlockPacket) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*BlockPacket) UnmarshalBinary ¶
func (s *BlockPacket) UnmarshalBinary(data []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
type BulkPullBlocksPacket ¶
func (*BulkPullBlocksPacket) ID ¶
func (s *BulkPullBlocksPacket) ID() byte
func (*BulkPullBlocksPacket) MarshalBinary ¶
func (s *BulkPullBlocksPacket) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*BulkPullBlocksPacket) UnmarshalBinary ¶
func (s *BulkPullBlocksPacket) UnmarshalBinary(data []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
type BulkPullMode ¶
type BulkPullMode byte
const ( BulkPullModeList BulkPullMode = iota BulkPullModeChecksum )
type BulkPullPacket ¶
func (*BulkPullPacket) ID ¶
func (s *BulkPullPacket) ID() byte
func (*BulkPullPacket) MarshalBinary ¶
func (s *BulkPullPacket) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*BulkPullPacket) UnmarshalBinary ¶
func (s *BulkPullPacket) UnmarshalBinary(data []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
type ConfirmAckPacket ¶
type ConfirmAckPacket VotePacket
func (*ConfirmAckPacket) ID ¶
func (s *ConfirmAckPacket) ID() byte
func (ConfirmAckPacket) MarshalBinary ¶
func (s ConfirmAckPacket) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*ConfirmAckPacket) UnmarshalBinary ¶
func (s *ConfirmAckPacket) UnmarshalBinary(data []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
type ConfirmReqPacket ¶
type ConfirmReqPacket BlockPacket
func (*ConfirmReqPacket) ID ¶
func (s *ConfirmReqPacket) ID() byte
func (ConfirmReqPacket) MarshalBinary ¶
func (s ConfirmReqPacket) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*ConfirmReqPacket) UnmarshalBinary ¶
func (s *ConfirmReqPacket) UnmarshalBinary(data []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
type FrontierReqPacket ¶
func (*FrontierReqPacket) ID ¶
func (s *FrontierReqPacket) ID() byte
func (*FrontierReqPacket) MarshalBinary ¶
func (s *FrontierReqPacket) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*FrontierReqPacket) UnmarshalBinary ¶
func (s *FrontierReqPacket) UnmarshalBinary(data []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
type HandshakePacket ¶
type HandshakePacket struct { }
func (*HandshakePacket) ID ¶
func (s *HandshakePacket) ID() byte
func (*HandshakePacket) MarshalBinary ¶
func (s *HandshakePacket) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*HandshakePacket) UnmarshalBinary ¶
func (s *HandshakePacket) UnmarshalBinary(data []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
type Header ¶
type Header struct { Magic [2]byte VersionMax byte VersionUsing byte VersionMin byte MessageType byte Extensions uint16 }
func (*Header) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*Header) SetBlockType ¶
func (*Header) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
type KeepAlivePacket ¶
func (*KeepAlivePacket) ID ¶
func (s *KeepAlivePacket) ID() byte
func (*KeepAlivePacket) MarshalBinary ¶
func (s *KeepAlivePacket) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*KeepAlivePacket) UnmarshalBinary ¶
func (s *KeepAlivePacket) UnmarshalBinary(data []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
type Network ¶
type Network rune
func (Network) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*Network) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type Packet ¶
type Packet interface { encoding.BinaryMarshaler encoding.BinaryUnmarshaler ID() byte }
type Proto ¶
type Proto struct {
// contains filtered or unexported fields
}
func (*Proto) NewKeepAlivePacket ¶
func (p *Proto) NewKeepAlivePacket(peers []*net.UDPAddr) *KeepAlivePacket
type PublishPacket ¶
type PublishPacket BlockPacket
func (*PublishPacket) ID ¶
func (s *PublishPacket) ID() byte
func (PublishPacket) MarshalBinary ¶
func (s PublishPacket) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*PublishPacket) UnmarshalBinary ¶
func (s *PublishPacket) UnmarshalBinary(data []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
type VotePacket ¶
func (VotePacket) MarshalBinary ¶
func (s VotePacket) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*VotePacket) UnmarshalBinary ¶
func (s *VotePacket) UnmarshalBinary(data []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.