Documentation ¶
Index ¶
- Constants
- Variables
- func IsValidCommand(c uint32) bool
- func IsValidReturnCode(c int32) bool
- func ParsePeerList(entry Entry) map[string]*Peer
- func ReadAny(bytes []byte, ttype byte) (int, interface{})
- func ReadString(bytes []byte) (int, string)
- func ReadVarInt(b []byte) (int, int)
- func VarIn(i int) ([]byte, error)
- func WithContextDialer(v ContextDialer) func(*ClientConfig)
- type BoostByte
- type BoostString
- type BoostUint32
- type BoostUint64
- type Client
- type ClientConfig
- type ClientOption
- type ContextDialer
- type Entries
- type Entry
- type Header
- type Node
- type Peer
- type PortableStorage
- type Section
- type Serializable
Constants ¶
View Source
const ( BoostSerializeTypeInt64 byte = 0x1 BoostSerializeTypeInt32 byte = 0x2 BoostSerializeTypeInt16 byte = 0x3 BoostSerializeTypeInt8 byte = 0x4 BoostSerializeTypeUint64 byte = 0x5 BoostSerializeTypeUint32 byte = 0x6 BoostSerializeTypeUint16 byte = 0x7 BoostSerializeTypeUint8 byte = 0x8 BoostSerializeTypeDouble byte = 0x9 BoostSerializeTypeString byte = 0x0a BoostSerializeTypeBool byte = 0x0b BoostSerializeTypeObject byte = 0x0c BoostSerializeTypeArray byte = 0xd BoostSerializeFlagArray byte = 0x80 )
View Source
const ( LevinSignature uint64 = 0x0101010101012101 // Dander's Nightmare LevinProtocolVersion uint32 = 1 LevinPacketRequest uint32 = 0x00000001 // Q flag LevinPacketReponse uint32 = 0x00000002 // S flag LevinPacketMaxDefaultSize uint64 = 100000000 // 100MB _after_ handshake LevinPacketMaxInitialSize uint64 = 256 * 1024 // 256KiB _before_ handshake LevinHeaderSizeBytes = 33 )
View Source
const ( // Return Codes. LevinOk int32 = 0 LevinErrorConnection int32 = -1 LevinErrorConnectionNotFound int32 = -2 LevinErrorConnectionDestroyed int32 = -3 LevinErrorConnectionTimedout int32 = -4 LevinErrorConnectionNoDuplexProtocol int32 = -5 LevinErrorConnectionHandlerNotDefined int32 = -6 LevinErrorFormat int32 = -7 )
View Source
const ( // p2p admin commands. CommandHandshake uint32 = 1001 CommandTimedSync uint32 = 1002 CommandPing uint32 = 1003 CommandStat uint32 = 1004 CommandNetworkState uint32 = 1005 CommandPeerID uint32 = 1006 CommandSupportFlags uint32 = 1007 )
View Source
const ( PortableStorageSignatureA uint32 = 0x01011101 PortableStorageSignatureB uint32 = 0x01020101 PortableStorageFormatVersion byte = 0x01 PortableRawSizeMarkMask byte = 0x03 PortableRawSizeMarkByte byte = 0x00 PortableRawSizeMarkWord uint16 = 0x01 PortableRawSizeMarkDword uint32 = 0x02 PortableRawSizeMarkInt64 uint64 = 0x03 )
View Source
const DialTimeout = 15 * time.Second
Variables ¶
View Source
var ( MainnetNetworkId = []byte{ 0x12, 0x30, 0xf1, 0x71, 0x61, 0x04, 0x41, 0x61, 0x17, 0x31, 0x00, 0x82, 0x16, 0xa1, 0xa1, 0x10, } MainnetGenesisTx = "418015bb9ae982a1975da7d79277c2705727a56894ba0fb246adaabb1f4632e3" )
Functions ¶
func IsValidCommand ¶
func IsValidReturnCode ¶
func ParsePeerList ¶
func ReadString ¶
func ReadVarInt ¶
reads var int, returning number of bytes read and the integer in that byte sequence.
func WithContextDialer ¶
func WithContextDialer(v ContextDialer) func(*ClientConfig)
Types ¶
type BoostString ¶
type BoostString string
func (BoostString) Bytes ¶
func (v BoostString) Bytes() []byte
type BoostUint32 ¶
type BoostUint32 uint32
func (BoostUint32) Bytes ¶
func (v BoostUint32) Bytes() []byte
type BoostUint64 ¶
type BoostUint64 uint64
func (BoostUint64) Bytes ¶
func (v BoostUint64) Bytes() []byte
type ClientConfig ¶
type ClientConfig struct {
ContextDialer ContextDialer
}
type ClientOption ¶
type ClientOption func(*ClientConfig)
type ContextDialer ¶
type Entry ¶
type Entry struct { Name string Serializable Serializable `json:"-,omitempty"` Value interface{} }
type Header ¶
type Header struct { Signature uint64 Length uint64 ExpectsResponse bool Command uint32 ReturnCode int32 Flags uint32 // only 4 most significant bits matter (Q|S|B|E) Version uint32 }
Header
0 1 2 3 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 0x01 | 0x21 | 0x01 | 0x01 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 0x01 | 0x01 | 0x01 | 0x01 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Length | | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | E. Response | _ Command _ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | _ Return Code _ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |Q|S|B|E| _ Reserved_ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 0x01 | 0x00 | 0x00 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 0x00 | +-+-+-+-+-+-+-+-+
i.e.,
BYTE(0X01) BYTE(0X21) BYTE(0X01) BYTE(0X01) ---. +--> protocol identification BYTE(0X01) BYTE(0X01) BYTE(0X01) BYTE(0X01) ---' UINT64(LENGTH) -----------------------------------> unsigned little-endian 64bit integer length of the payload _not including_ the header. messages >100MB are rejected. BYTE(E.RESPONSE) 4BYTE(COMMAND) 4BYTE(RET CODE) | | | | | | | | '-> signed 32-bit little endian integer representing the response | | from the peer from the last command invoked. `0` for request msgs. | | | '-> unsigned 32-bit little endian integer | representing the monero specific cmd | '-> zero-byte if no response is expected from the peer, non-zero if response is expected. peers must respond to requests w/ this flag in the same order as received. BIT(Q) BIT(S) BIT(B) BIT(E) 3BYTE+4BIT(RESERVED) | | | | | | | | | | | '-> set if this is the end of a frag msg | | | | | '-> set if this is the beginning of a frag msg | | | '-> set if the message is a response | '-> set if the message is a request BYTE(0X01) BYTE(0X00) BYTE(0X00) BYTE(0X00) | '--> version
func NewHeaderFromBytesBytes ¶
func NewRequestHeader ¶
type Node ¶
type PortableStorage ¶
type PortableStorage struct {
Entries Entries
}
func NewPortableStorageFromBytes ¶
func NewPortableStorageFromBytes(bytes []byte) (*PortableStorage, error)
func (*PortableStorage) Bytes ¶
func (s *PortableStorage) Bytes() []byte
type Serializable ¶
type Serializable interface {
Bytes() []byte
}
Click to show internal directories.
Click to hide internal directories.