amperp2p

package
v0.0.0-...-d9e9996 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AmperMsgVersion1 = "1.0.0"
	AmperMsgVersion2 = "2.0.0"
)

define message versions

Variables

View Source
var AmperMessage_ErrorType_name = map[int32]string{
	0:  "SUCCESS",
	1:  "NONE",
	2:  "UNKNOW_ERROR",
	3:  "CHECK_SUM_ERROR",
	4:  "UNMARSHAL_MSG_BODY_ERROR",
	5:  "CONNECT_REFUSE",
	6:  "GET_BLOCKCHAIN_ERROR",
	7:  "BLOCKCHAIN_NOTEXIST",
	8:  "GET_BLOCK_ERROR",
	9:  "CONFIRM_BLOCKCHAINSTATUS_ERROR",
	10: "GET_AUTHENTICATION_ERROR",
	11: "GET_AUTHENTICATION_NOT_PASS",
}
View Source
var AmperMessage_ErrorType_value = map[string]int32{
	"SUCCESS":                        0,
	"NONE":                           1,
	"UNKNOW_ERROR":                   2,
	"CHECK_SUM_ERROR":                3,
	"UNMARSHAL_MSG_BODY_ERROR":       4,
	"CONNECT_REFUSE":                 5,
	"GET_BLOCKCHAIN_ERROR":           6,
	"BLOCKCHAIN_NOTEXIST":            7,
	"GET_BLOCK_ERROR":                8,
	"CONFIRM_BLOCKCHAINSTATUS_ERROR": 9,
	"GET_AUTHENTICATION_ERROR":       10,
	"GET_AUTHENTICATION_NOT_PASS":    11,
}
View Source
var AmperMessage_MessageType_name = map[int32]string{
	0:  "SENDBLOCK",
	1:  "POSTTX",
	2:  "BATCHPOSTTX",
	3:  "GET_BLOCK",
	4:  "PING",
	5:  "GET_BLOCKCHAINSTATUS",
	6:  "GET_BLOCK_RES",
	7:  "GET_BLOCKCHAINSTATUS_RES",
	8:  "CONFIRM_BLOCKCHAINSTATUS",
	9:  "CONFIRM_BLOCKCHAINSTATUS_RES",
	10: "MSG_TYPE_NONE",
	11: "GET_RPC_PORT",
	12: "GET_RPC_PORT_RES",
	13: "GET_AUTHENTICATION",
	14: "GET_AUTHENTICATION_RES",
}
View Source
var AmperMessage_MessageType_value = map[string]int32{
	"SENDBLOCK":                    0,
	"POSTTX":                       1,
	"BATCHPOSTTX":                  2,
	"GET_BLOCK":                    3,
	"PING":                         4,
	"GET_BLOCKCHAINSTATUS":         5,
	"GET_BLOCK_RES":                6,
	"GET_BLOCKCHAINSTATUS_RES":     7,
	"CONFIRM_BLOCKCHAINSTATUS":     8,
	"CONFIRM_BLOCKCHAINSTATUS_RES": 9,
	"MSG_TYPE_NONE":                10,
	"GET_RPC_PORT":                 11,
	"GET_RPC_PORT_RES":             12,
	"GET_AUTHENTICATION":           13,
	"GET_AUTHENTICATION_RES":       14,
}

Functions

func CalDataCheckSum

func CalDataCheckSum(msg *AmperMessage) uint32

CalDataCheckSum calculate checksum of message

func VerifyDataCheckSum

func VerifyDataCheckSum(msg *AmperMessage) bool

VerifyDataCheckSum verify the checksum of message

func VerifyMsgMatch

func VerifyMsgMatch(msgRaw *AmperMessage, msgNew *AmperMessage, peerID string) bool

VerifyMsgMatch 用于带返回的请求场景下验证收到的消息是否为预期的消息

Types

type AmperMessage

type AmperMessage struct {
	Header               *AmperMessage_MessageHeader `protobuf:"bytes,1,opt,name=Header,proto3" json:"Header,omitempty"`
	Data                 *AmperMessage_MessageData   `protobuf:"bytes,2,opt,name=Data,proto3" json:"Data,omitempty"`
	XXX_NoUnkeyedLiteral struct{}                    `json:"-"`
	XXX_unrecognized     []byte                      `json:"-"`
	XXX_sizecache        int32                       `json:"-"`
}

AmperMessage is the message of Amper p2p server

func NewAmperMessage

func NewAmperMessage(version, bcName, lgid string, tp AmperMessage_MessageType, msgInfo []byte, ep AmperMessage_ErrorType) (*AmperMessage, error)

NewAmperMessage create P2P message instance with given params

func (*AmperMessage) Descriptor

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

func (*AmperMessage) GetData

func (m *AmperMessage) GetData() *AmperMessage_MessageData

func (*AmperMessage) GetHeader

func (m *AmperMessage) GetHeader() *AmperMessage_MessageHeader

func (*AmperMessage) ProtoMessage

func (*AmperMessage) ProtoMessage()

func (*AmperMessage) Reset

func (m *AmperMessage) Reset()

func (*AmperMessage) String

func (m *AmperMessage) String() string

func (*AmperMessage) XXX_DiscardUnknown

func (m *AmperMessage) XXX_DiscardUnknown()

func (*AmperMessage) XXX_Marshal

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

func (*AmperMessage) XXX_Merge

func (m *AmperMessage) XXX_Merge(src proto.Message)

func (*AmperMessage) XXX_Size

func (m *AmperMessage) XXX_Size() int

func (*AmperMessage) XXX_Unmarshal

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

type AmperMessage_ErrorType

type AmperMessage_ErrorType int32
const (
	// success
	AmperMessage_SUCCESS AmperMessage_ErrorType = 0
	AmperMessage_NONE    AmperMessage_ErrorType = 1
	// common error
	AmperMessage_UNKNOW_ERROR             AmperMessage_ErrorType = 2
	AmperMessage_CHECK_SUM_ERROR          AmperMessage_ErrorType = 3
	AmperMessage_UNMARSHAL_MSG_BODY_ERROR AmperMessage_ErrorType = 4
	AmperMessage_CONNECT_REFUSE           AmperMessage_ErrorType = 5
	// block error
	AmperMessage_GET_BLOCKCHAIN_ERROR           AmperMessage_ErrorType = 6
	AmperMessage_BLOCKCHAIN_NOTEXIST            AmperMessage_ErrorType = 7
	AmperMessage_GET_BLOCK_ERROR                AmperMessage_ErrorType = 8
	AmperMessage_CONFIRM_BLOCKCHAINSTATUS_ERROR AmperMessage_ErrorType = 9
	AmperMessage_GET_AUTHENTICATION_ERROR       AmperMessage_ErrorType = 10
	AmperMessage_GET_AUTHENTICATION_NOT_PASS    AmperMessage_ErrorType = 11
)

func (AmperMessage_ErrorType) EnumDescriptor

func (AmperMessage_ErrorType) EnumDescriptor() ([]byte, []int)

func (AmperMessage_ErrorType) String

func (x AmperMessage_ErrorType) String() string

type AmperMessage_MessageData

type AmperMessage_MessageData struct {
	// msgInfo is the message infomation, use protobuf coding style
	MsgInfo              []byte   `protobuf:"bytes,3,opt,name=msgInfo,proto3" json:"msgInfo,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

MessageData is the message data of Amper p2p server

func (*AmperMessage_MessageData) Descriptor

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

func (*AmperMessage_MessageData) GetMsgInfo

func (m *AmperMessage_MessageData) GetMsgInfo() []byte

func (*AmperMessage_MessageData) ProtoMessage

func (*AmperMessage_MessageData) ProtoMessage()

func (*AmperMessage_MessageData) Reset

func (m *AmperMessage_MessageData) Reset()

func (*AmperMessage_MessageData) String

func (m *AmperMessage_MessageData) String() string

func (*AmperMessage_MessageData) XXX_DiscardUnknown

func (m *AmperMessage_MessageData) XXX_DiscardUnknown()

func (*AmperMessage_MessageData) XXX_Marshal

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

func (*AmperMessage_MessageData) XXX_Merge

func (m *AmperMessage_MessageData) XXX_Merge(src proto.Message)

func (*AmperMessage_MessageData) XXX_Size

func (m *AmperMessage_MessageData) XXX_Size() int

func (*AmperMessage_MessageData) XXX_Unmarshal

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

type AmperMessage_MessageHeader

type AmperMessage_MessageHeader struct {
	Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"`
	// dataCheckSum is the message data checksum, it can be used check where the message have been received
	Logid                string                   `protobuf:"bytes,2,opt,name=logid,proto3" json:"logid,omitempty"`
	From                 string                   `protobuf:"bytes,3,opt,name=from,proto3" json:"from,omitempty"`
	Bcname               string                   `protobuf:"bytes,4,opt,name=bcname,proto3" json:"bcname,omitempty"`
	Type                 AmperMessage_MessageType `protobuf:"varint,5,opt,name=type,proto3,enum=amperp2p.AmperMessage_MessageType" json:"type,omitempty"`
	DataCheckSum         uint32                   `protobuf:"varint,6,opt,name=dataCheckSum,proto3" json:"dataCheckSum,omitempty"`
	ErrorType            AmperMessage_ErrorType   `protobuf:"varint,7,opt,name=errorType,proto3,enum=amperp2p.AmperMessage_ErrorType" json:"errorType,omitempty"`
	XXX_NoUnkeyedLiteral struct{}                 `json:"-"`
	XXX_unrecognized     []byte                   `json:"-"`
	XXX_sizecache        int32                    `json:"-"`
}

MessageHeader is the message header of Amper p2p server

func (*AmperMessage_MessageHeader) Descriptor

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

func (*AmperMessage_MessageHeader) GetBcname

func (m *AmperMessage_MessageHeader) GetBcname() string

func (*AmperMessage_MessageHeader) GetDataCheckSum

func (m *AmperMessage_MessageHeader) GetDataCheckSum() uint32

func (*AmperMessage_MessageHeader) GetErrorType

func (*AmperMessage_MessageHeader) GetFrom

func (m *AmperMessage_MessageHeader) GetFrom() string

func (*AmperMessage_MessageHeader) GetLogid

func (m *AmperMessage_MessageHeader) GetLogid() string

func (*AmperMessage_MessageHeader) GetType

func (*AmperMessage_MessageHeader) GetVersion

func (m *AmperMessage_MessageHeader) GetVersion() string

func (*AmperMessage_MessageHeader) ProtoMessage

func (*AmperMessage_MessageHeader) ProtoMessage()

func (*AmperMessage_MessageHeader) Reset

func (m *AmperMessage_MessageHeader) Reset()

func (*AmperMessage_MessageHeader) String

func (m *AmperMessage_MessageHeader) String() string

func (*AmperMessage_MessageHeader) XXX_DiscardUnknown

func (m *AmperMessage_MessageHeader) XXX_DiscardUnknown()

func (*AmperMessage_MessageHeader) XXX_Marshal

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

func (*AmperMessage_MessageHeader) XXX_Merge

func (m *AmperMessage_MessageHeader) XXX_Merge(src proto.Message)

func (*AmperMessage_MessageHeader) XXX_Size

func (m *AmperMessage_MessageHeader) XXX_Size() int

func (*AmperMessage_MessageHeader) XXX_Unmarshal

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

type AmperMessage_MessageType

type AmperMessage_MessageType int32
const (
	AmperMessage_SENDBLOCK                AmperMessage_MessageType = 0
	AmperMessage_POSTTX                   AmperMessage_MessageType = 1
	AmperMessage_BATCHPOSTTX              AmperMessage_MessageType = 2
	AmperMessage_GET_BLOCK                AmperMessage_MessageType = 3
	AmperMessage_PING                     AmperMessage_MessageType = 4
	AmperMessage_GET_BLOCKCHAINSTATUS     AmperMessage_MessageType = 5
	AmperMessage_GET_BLOCK_RES            AmperMessage_MessageType = 6
	AmperMessage_GET_BLOCKCHAINSTATUS_RES AmperMessage_MessageType = 7
	// 向邻近确认区块是否为最新状态区块
	AmperMessage_CONFIRM_BLOCKCHAINSTATUS     AmperMessage_MessageType = 8
	AmperMessage_CONFIRM_BLOCKCHAINSTATUS_RES AmperMessage_MessageType = 9
	AmperMessage_MSG_TYPE_NONE                AmperMessage_MessageType = 10
	// 询问RPC端口信息
	AmperMessage_GET_RPC_PORT           AmperMessage_MessageType = 11
	AmperMessage_GET_RPC_PORT_RES       AmperMessage_MessageType = 12
	AmperMessage_GET_AUTHENTICATION     AmperMessage_MessageType = 13
	AmperMessage_GET_AUTHENTICATION_RES AmperMessage_MessageType = 14
)

func GetResMsgType

GetResMsgType get the message type

func (AmperMessage_MessageType) EnumDescriptor

func (AmperMessage_MessageType) EnumDescriptor() ([]byte, []int)

func (AmperMessage_MessageType) String

func (x AmperMessage_MessageType) String() string

Jump to

Keyboard shortcuts

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