proto

package
v0.0.0-...-c9d2d86 Latest Latest
Warning

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

Go to latest
Published: May 25, 2018 License: ISC Imports: 8 Imported by: 0

Documentation

Overview

Package proto is a generated protocol buffer package.

It is generated from these files:

block.proto
message.proto
transaction.proto

It has these top-level messages:

BlockHeader
Block
GetBlocksMsg
StatusMsg
GetInvMsg
OnBlockMsg
OnTransactionMsg
GetDataMsg
ContractSpec
TxHeader
Transaction

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptySignature represents no signature
	ErrEmptySignature = errors.New("Signature Empty Error")
)
View Source
var InvType_name = map[int32]string{
	0: "block",
	1: "transaction",
}
View Source
var InvType_value = map[string]int32{
	"block":       0,
	"transaction": 1,
}
View Source
var MsgType_name = map[int32]string{
	0: "BC_GetBlocksMsg",
	1: "BC_GetInvMsg",
	2: "BC_GetDataMsg",
	3: "BC_OnBlockMsg",
	4: "BC_OnTransactionMsg",
	5: "BC_OnStatusMSg",
	6: "BC_OnConsensusMSg",
}
View Source
var MsgType_value = map[string]int32{
	"BC_GetBlocksMsg":     0,
	"BC_GetInvMsg":        1,
	"BC_GetDataMsg":       2,
	"BC_OnBlockMsg":       3,
	"BC_OnTransactionMsg": 4,
	"BC_OnStatusMSg":      5,
	"BC_OnConsensusMSg":   6,
}
View Source
var ProtoID_name = map[int32]string{
	0: "NA",
	1: "SyncWorker",
	2: "ConsensusWorker",
}
View Source
var ProtoID_value = map[string]int32{
	"NA":              0,
	"SyncWorker":      1,
	"ConsensusWorker": 2,
}
View Source
var TransactionType_name = map[int32]string{
	0:  "Atomic",
	1:  "AcrossChain",
	2:  "Merged",
	3:  "Backfront",
	4:  "Distribut",
	5:  "Issue",
	6:  "IssueUpdate",
	7:  "JSContractInit",
	8:  "LuaContractInit",
	9:  "ContractInvoke",
	10: "ContractQuery",
	11: "Security",
}
View Source
var TransactionType_value = map[string]int32{
	"Atomic":          0,
	"AcrossChain":     1,
	"Merged":          2,
	"Backfront":       3,
	"Distribut":       4,
	"Issue":           5,
	"IssueUpdate":     6,
	"JSContractInit":  7,
	"LuaContractInit": 8,
	"ContractInvoke":  9,
	"ContractQuery":   10,
	"Security":        11,
}

Functions

This section is empty.

Types

type Block

type Block struct {
	Header       *BlockHeader   `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
	Transactions []*Transaction `protobuf:"bytes,2,rep,name=transactions" json:"transactions,omitempty"`
}

func NewBlock

func NewBlock(prvHash, stateHash crypto.Hash,
	timeStamp, height, nonce uint32,
	txsHash crypto.Hash,
	Txs Transactions) *Block

NewBlock returns an new block

func (*Block) Descriptor

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

func (*Block) Deserialize

func (b *Block) Deserialize(data []byte) error

Deserialize deserializes bytes to Block

func (*Block) GetHeader

func (m *Block) GetHeader() *BlockHeader

func (*Block) GetTransactions

func (m *Block) GetTransactions() []*Transaction

func (*Block) Hash

func (b *Block) Hash() crypto.Hash

Hash returns the hash of the blockheader in block

func (*Block) Height

func (b *Block) Height() uint32

Height returns the block height

func (*Block) PreviousHash

func (b *Block) PreviousHash() string

PreviousHash returns the previous hash of the block

func (*Block) ProtoMessage

func (*Block) ProtoMessage()

func (*Block) Reset

func (m *Block) Reset()

func (*Block) Serialize

func (b *Block) Serialize() []byte

Serialize block data marshal

func (*Block) String

func (m *Block) String() string

type BlockHeader

type BlockHeader struct {
	PreviousHash  string `protobuf:"bytes,1,opt,name=previousHash" json:"previousHash,omitempty"`
	StateHash     string `protobuf:"bytes,2,opt,name=stateHash" json:"stateHash,omitempty"`
	TimeStamp     uint32 `protobuf:"varint,3,opt,name=timeStamp" json:"timeStamp,omitempty"`
	Nonce         uint32 `protobuf:"varint,4,opt,name=nonce" json:"nonce,omitempty"`
	TxsMerkleHash string `protobuf:"bytes,5,opt,name=txsMerkleHash" json:"txsMerkleHash,omitempty"`
	Height        uint32 `protobuf:"varint,6,opt,name=height" json:"height,omitempty"`
}

func NewBlockHeader

func NewBlockHeader(prvHash, stateHash crypto.Hash, timeStamp, height, nonce uint32, txsHash crypto.Hash) *BlockHeader

NewBlockHeader returns a blockheader

func (*BlockHeader) Descriptor

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

func (*BlockHeader) Deserialize

func (bh *BlockHeader) Deserialize(data []byte) error

Deserialize deserialize the input data to header

func (*BlockHeader) GetHeight

func (m *BlockHeader) GetHeight() uint32

func (*BlockHeader) GetNonce

func (m *BlockHeader) GetNonce() uint32

func (*BlockHeader) GetPreviousHash

func (m *BlockHeader) GetPreviousHash() string

func (*BlockHeader) GetStateHash

func (m *BlockHeader) GetStateHash() string

func (*BlockHeader) GetTimeStamp

func (m *BlockHeader) GetTimeStamp() uint32

func (*BlockHeader) GetTxsMerkleHash

func (m *BlockHeader) GetTxsMerkleHash() string

func (*BlockHeader) Hash

func (bh *BlockHeader) Hash() crypto.Hash

Hash returns the hash of the blockheader

func (*BlockHeader) ProtoMessage

func (*BlockHeader) ProtoMessage()

func (*BlockHeader) Reset

func (m *BlockHeader) Reset()

func (*BlockHeader) Serialize

func (bh *BlockHeader) Serialize() []byte

Serialize returns the serialized bytes of a blockheader

func (*BlockHeader) String

func (m *BlockHeader) String() string

type ContractSpec

type ContractSpec struct {
	Addr   []byte   `protobuf:"bytes,1,opt,name=addr,proto3" json:"addr,omitempty"`
	Code   []byte   `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"`
	Params []string `protobuf:"bytes,3,rep,name=params" json:"params,omitempty"`
}

func (*ContractSpec) Descriptor

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

func (*ContractSpec) GetAddr

func (m *ContractSpec) GetAddr() []byte

func (*ContractSpec) GetCode

func (m *ContractSpec) GetCode() []byte

func (*ContractSpec) GetParams

func (m *ContractSpec) GetParams() []string

func (*ContractSpec) ProtoMessage

func (*ContractSpec) ProtoMessage()

func (*ContractSpec) Reset

func (m *ContractSpec) Reset()

func (*ContractSpec) String

func (m *ContractSpec) String() string

type GetBlocksMsg

type GetBlocksMsg struct {
	Version       uint32   `protobuf:"varint,1,opt,name=version" json:"version,omitempty"`
	LocatorHashes []string `protobuf:"bytes,2,rep,name=locatorHashes" json:"locatorHashes,omitempty"`
	HashStop      string   `protobuf:"bytes,3,opt,name=hashStop" json:"hashStop,omitempty"`
}

func (*GetBlocksMsg) Descriptor

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

func (*GetBlocksMsg) GetHashStop

func (m *GetBlocksMsg) GetHashStop() string

func (*GetBlocksMsg) GetLocatorHashes

func (m *GetBlocksMsg) GetLocatorHashes() []string

func (*GetBlocksMsg) GetVersion

func (m *GetBlocksMsg) GetVersion() uint32

func (*GetBlocksMsg) MarshalMsg

func (m *GetBlocksMsg) MarshalMsg() ([]byte, error)

func (*GetBlocksMsg) ProtoMessage

func (*GetBlocksMsg) ProtoMessage()

func (*GetBlocksMsg) Reset

func (m *GetBlocksMsg) Reset()

func (*GetBlocksMsg) String

func (m *GetBlocksMsg) String() string

func (*GetBlocksMsg) UnmarshalMsg

func (m *GetBlocksMsg) UnmarshalMsg(data []byte) error

type GetDataMsg

type GetDataMsg struct {
	InvList []*GetInvMsg `protobuf:"bytes,1,rep,name=InvList" json:"InvList,omitempty"`
}

func (*GetDataMsg) Descriptor

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

func (*GetDataMsg) GetInvList

func (m *GetDataMsg) GetInvList() []*GetInvMsg

func (*GetDataMsg) MarshalMsg

func (m *GetDataMsg) MarshalMsg() ([]byte, error)

func (*GetDataMsg) ProtoMessage

func (*GetDataMsg) ProtoMessage()

func (*GetDataMsg) Reset

func (m *GetDataMsg) Reset()

func (*GetDataMsg) String

func (m *GetDataMsg) String() string

func (*GetDataMsg) UnmarshalMsg

func (m *GetDataMsg) UnmarshalMsg(data []byte) error

type GetInvMsg

type GetInvMsg struct {
	Type  InvType  `protobuf:"varint,1,opt,name=type,enum=proto.InvType" json:"type,omitempty"`
	Hashs []string `protobuf:"bytes,2,rep,name=hashs" json:"hashs,omitempty"`
}

func (*GetInvMsg) Descriptor

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

func (*GetInvMsg) GetHashs

func (m *GetInvMsg) GetHashs() []string

func (*GetInvMsg) GetType

func (m *GetInvMsg) GetType() InvType

func (*GetInvMsg) MarshalMsg

func (m *GetInvMsg) MarshalMsg() ([]byte, error)

func (*GetInvMsg) ProtoMessage

func (*GetInvMsg) ProtoMessage()

func (*GetInvMsg) Reset

func (m *GetInvMsg) Reset()

func (*GetInvMsg) String

func (m *GetInvMsg) String() string

func (*GetInvMsg) UnmarshalMsg

func (m *GetInvMsg) UnmarshalMsg(data []byte) error

type IInventory

type IInventory interface {
	Hash() crypto.Hash
	Serialize() []byte
}

IInventory defines interface that broadcast data should implements

type IMsg

type IMsg interface {
	MarshalMsg() ([]byte, error)
	UnmarshalMsg(data []byte) error
}

type InvType

type InvType int32
const (
	InvType_block       InvType = 0
	InvType_transaction InvType = 1
)

func (InvType) EnumDescriptor

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

func (InvType) String

func (x InvType) String() string

type MsgType

type MsgType int32
const (
	MsgType_BC_GetBlocksMsg     MsgType = 0
	MsgType_BC_GetInvMsg        MsgType = 1
	MsgType_BC_GetDataMsg       MsgType = 2
	MsgType_BC_OnBlockMsg       MsgType = 3
	MsgType_BC_OnTransactionMsg MsgType = 4
	MsgType_BC_OnStatusMSg      MsgType = 5
	MsgType_BC_OnConsensusMSg   MsgType = 6
)

func (MsgType) EnumDescriptor

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

func (MsgType) String

func (x MsgType) String() string

type OnBlockMsg

type OnBlockMsg struct {
	Block *Block `protobuf:"bytes,1,opt,name=block" json:"block,omitempty"`
}

func (*OnBlockMsg) Descriptor

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

func (*OnBlockMsg) GetBlock

func (m *OnBlockMsg) GetBlock() *Block

func (*OnBlockMsg) MarshalMsg

func (m *OnBlockMsg) MarshalMsg() ([]byte, error)

func (*OnBlockMsg) ProtoMessage

func (*OnBlockMsg) ProtoMessage()

func (*OnBlockMsg) Reset

func (m *OnBlockMsg) Reset()

func (*OnBlockMsg) String

func (m *OnBlockMsg) String() string

func (*OnBlockMsg) UnmarshalMsg

func (m *OnBlockMsg) UnmarshalMsg(data []byte) error

type OnTransactionMsg

type OnTransactionMsg struct {
	Transaction *Transaction `protobuf:"bytes,1,opt,name=transaction" json:"transaction,omitempty"`
}

func (*OnTransactionMsg) Descriptor

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

func (*OnTransactionMsg) GetTransaction

func (m *OnTransactionMsg) GetTransaction() *Transaction

func (*OnTransactionMsg) MarshalMsg

func (m *OnTransactionMsg) MarshalMsg() ([]byte, error)

func (*OnTransactionMsg) ProtoMessage

func (*OnTransactionMsg) ProtoMessage()

func (*OnTransactionMsg) Reset

func (m *OnTransactionMsg) Reset()

func (*OnTransactionMsg) String

func (m *OnTransactionMsg) String() string

func (*OnTransactionMsg) UnmarshalMsg

func (m *OnTransactionMsg) UnmarshalMsg(data []byte) error

type ProtoID

type ProtoID int32
const (
	ProtoID_NA              ProtoID = 0
	ProtoID_SyncWorker      ProtoID = 1
	ProtoID_ConsensusWorker ProtoID = 2
)

func (ProtoID) EnumDescriptor

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

func (ProtoID) String

func (x ProtoID) String() string

type StatusMsg

type StatusMsg struct {
	Version     uint32 `protobuf:"varint,1,opt,name=Version" json:"Version,omitempty"`
	StartHeight uint32 `protobuf:"varint,2,opt,name=StartHeight" json:"StartHeight,omitempty"`
}

func (*StatusMsg) Descriptor

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

func (*StatusMsg) GetStartHeight

func (m *StatusMsg) GetStartHeight() uint32

func (*StatusMsg) GetVersion

func (m *StatusMsg) GetVersion() uint32

func (*StatusMsg) MarshalMsg

func (m *StatusMsg) MarshalMsg() ([]byte, error)

func (*StatusMsg) ProtoMessage

func (*StatusMsg) ProtoMessage()

func (*StatusMsg) Reset

func (m *StatusMsg) Reset()

func (*StatusMsg) String

func (m *StatusMsg) String() string

func (*StatusMsg) UnmarshalMsg

func (m *StatusMsg) UnmarshalMsg(data []byte) error

type Transaction

type Transaction struct {
	Header       *TxHeader     `protobuf:"bytes,1,opt,name=Header" json:"Header,omitempty"`
	Payload      []byte        `protobuf:"bytes,2,opt,name=payload,proto3" json:"payload,omitempty"`
	Meta         []byte        `protobuf:"bytes,3,opt,name=meta,proto3" json:"meta,omitempty"`
	ContractSpec *ContractSpec `protobuf:"bytes,4,opt,name=contractSpec" json:"contractSpec,omitempty"`
}

func NewTransaction

func NewTransaction(from, to account.ChainCoordinate,
	txType TransactionType,
	nonce uint32,
	sender, recipient account.Address,
	assetID uint32,
	amount, fee int64,
	createTime uint32) *Transaction

NewTransaction initialization transaction

func (*Transaction) Amount

func (tx *Transaction) Amount() int64

Amount returns the transfer �amount of the transaction

func (*Transaction) AssetID

func (tx *Transaction) AssetID() uint32

AssetID returns the transfer asset of the transaction

func (*Transaction) Compare

func (tx *Transaction) Compare(v interface{}) int

Compare implements interface consensus need

func (*Transaction) CreateTime

func (tx *Transaction) CreateTime() uint32

CreateTime returns the create time of the transaction

func (*Transaction) Descriptor

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

func (*Transaction) Deserialize

func (tx *Transaction) Deserialize(data []byte) error

Deserialize deserializes bytes to a transaction

func (*Transaction) Fee

func (tx *Transaction) Fee() int64

Fee returns the nonce of the transaction

func (*Transaction) FromChain

func (tx *Transaction) FromChain() string

FromChain returns the chain coordinate of the sender

func (*Transaction) GetContractSpec

func (m *Transaction) GetContractSpec() *ContractSpec

func (*Transaction) GetHeader

func (m *Transaction) GetHeader() *TxHeader

func (*Transaction) GetMeta

func (m *Transaction) GetMeta() []byte

func (*Transaction) GetPayload

func (m *Transaction) GetPayload() []byte

func (*Transaction) GetType

func (tx *Transaction) GetType() TransactionType

GetType returns transaction type

func (*Transaction) Hash

func (tx *Transaction) Hash() crypto.Hash

Hash returns the hash of a transaction

func (*Transaction) IsLocalChain

func (tx *Transaction) IsLocalChain() bool

IsLocalChain returns whether or not local chain

func (*Transaction) Nonce

func (tx *Transaction) Nonce() uint32

Nonce returns the nonce of the transaction

func (*Transaction) ProtoMessage

func (*Transaction) ProtoMessage()

func (*Transaction) Recipient

func (tx *Transaction) Recipient() account.Address

Recipient returns the address of the recipient

func (*Transaction) Reset

func (m *Transaction) Reset()

func (*Transaction) Sender

func (tx *Transaction) Sender() account.Address

Sender returns the address of the sender.

func (*Transaction) Serialize

func (tx *Transaction) Serialize() []byte

Serialize marshal txData proto message

func (*Transaction) SignHash

func (tx *Transaction) SignHash() crypto.Hash

SignHash returns the hash of a raw transaction before sign

func (*Transaction) String

func (m *Transaction) String() string

func (*Transaction) ToChain

func (tx *Transaction) ToChain() string

ToChain returns the chain coordinate of the recipient

func (*Transaction) Verfiy

func (tx *Transaction) Verfiy() (account.Address, error)

Verfiy Also can use this method verify signature

func (*Transaction) WithSignature

func (tx *Transaction) WithSignature(sig *crypto.Signature)

WithSignature returns a new transaction with the given signature.

type TransactionType

type TransactionType int32
const (
	TransactionType_Atomic          TransactionType = 0
	TransactionType_AcrossChain     TransactionType = 1
	TransactionType_Merged          TransactionType = 2
	TransactionType_Backfront       TransactionType = 3
	TransactionType_Distribut       TransactionType = 4
	TransactionType_Issue           TransactionType = 5
	TransactionType_IssueUpdate     TransactionType = 6
	TransactionType_JSContractInit  TransactionType = 7
	TransactionType_LuaContractInit TransactionType = 8
	TransactionType_ContractInvoke  TransactionType = 9
	TransactionType_ContractQuery   TransactionType = 10
	TransactionType_Security        TransactionType = 11
)

func (TransactionType) EnumDescriptor

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

func (TransactionType) String

func (x TransactionType) String() string

type Transactions

type Transactions []*Transaction

Transactions represents transaction slice type for basic sorting.

func (Transactions) Len

func (s Transactions) Len() int

Len returns the length of s

func (Transactions) Less

func (s Transactions) Less(i, j int) bool

Less compares nonce of the i'th and the j'th element in s

func (Transactions) Swap

func (s Transactions) Swap(i, j int)

Swap swaps the i'th and the j'th element in s

type TxHeader

type TxHeader struct {
	FromChain  []byte          `protobuf:"bytes,1,opt,name=fromChain,proto3" json:"fromChain,omitempty"`
	ToChain    []byte          `protobuf:"bytes,2,opt,name=toChain,proto3" json:"toChain,omitempty"`
	Type       TransactionType `protobuf:"varint,3,opt,name=type,enum=proto.TransactionType" json:"type,omitempty"`
	Nonce      uint32          `protobuf:"varint,4,opt,name=nonce" json:"nonce,omitempty"`
	Sender     string          `protobuf:"bytes,5,opt,name=sender" json:"sender,omitempty"`
	Recipient  string          `protobuf:"bytes,6,opt,name=recipient" json:"recipient,omitempty"`
	AssetID    uint32          `protobuf:"varint,7,opt,name=assetID" json:"assetID,omitempty"`
	Amount     int64           `protobuf:"varint,8,opt,name=amount" json:"amount,omitempty"`
	Fee        int64           `protobuf:"varint,9,opt,name=fee" json:"fee,omitempty"`
	Signature  []byte          `protobuf:"bytes,10,opt,name=signature,proto3" json:"signature,omitempty"`
	CreateTime uint32          `protobuf:"varint,11,opt,name=createTime" json:"createTime,omitempty"`
}

func (*TxHeader) Descriptor

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

func (*TxHeader) GetAmount

func (m *TxHeader) GetAmount() int64

func (*TxHeader) GetAssetID

func (m *TxHeader) GetAssetID() uint32

func (*TxHeader) GetCreateTime

func (m *TxHeader) GetCreateTime() uint32

func (*TxHeader) GetFee

func (m *TxHeader) GetFee() int64

func (*TxHeader) GetFromChain

func (m *TxHeader) GetFromChain() []byte

func (*TxHeader) GetNonce

func (m *TxHeader) GetNonce() uint32

func (*TxHeader) GetRecipient

func (m *TxHeader) GetRecipient() string

func (*TxHeader) GetSender

func (m *TxHeader) GetSender() string

func (*TxHeader) GetSignature

func (m *TxHeader) GetSignature() []byte

func (*TxHeader) GetToChain

func (m *TxHeader) GetToChain() []byte

func (*TxHeader) GetType

func (m *TxHeader) GetType() TransactionType

func (*TxHeader) ProtoMessage

func (*TxHeader) ProtoMessage()

func (*TxHeader) Reset

func (m *TxHeader) Reset()

func (*TxHeader) String

func (m *TxHeader) String() string

Jump to

Keyboard shortcuts

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