tx

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2018 License: LGPL-3.0 Imports: 12 Imported by: 42

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func SignTxContent

func SignTxContent(tx *Tx, account *account.Account) (*crypto.Signature, error)

SignTxContent sign tx content, only signers should do this

Types

type Action

type Action struct {
	Contract   string // contract name
	ActionName string // method name of contract
	Data       string // parameters of method, with json format
}

Action implement

func NewAction

func NewAction(contract string, name string, data string) Action

NewAction constructor of Action

func (*Action) Decode

func (a *Action) Decode(b []byte) error

Decode action from byte array

func (*Action) Encode

func (a *Action) Encode() []byte

Encode encode action as byte array

func (*Action) String

func (a *Action) String() string

String return human readable string

type ActionRaw

type ActionRaw struct {
	Contract             string   `protobuf:"bytes,1,opt,name=contract,proto3" json:"contract,omitempty"`
	ActionName           string   `protobuf:"bytes,2,opt,name=actionName,proto3" json:"actionName,omitempty"`
	Data                 string   `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*ActionRaw) Descriptor

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

func (*ActionRaw) GetActionName

func (m *ActionRaw) GetActionName() string

func (*ActionRaw) GetContract

func (m *ActionRaw) GetContract() string

func (*ActionRaw) GetData

func (m *ActionRaw) GetData() string

func (*ActionRaw) Marshal

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

func (*ActionRaw) MarshalTo

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

func (*ActionRaw) ProtoMessage

func (*ActionRaw) ProtoMessage()

func (*ActionRaw) Reset

func (m *ActionRaw) Reset()

func (*ActionRaw) Size

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

func (*ActionRaw) String

func (m *ActionRaw) String() string

func (*ActionRaw) Unmarshal

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

func (*ActionRaw) XXX_DiscardUnknown

func (m *ActionRaw) XXX_DiscardUnknown()

func (*ActionRaw) XXX_Marshal

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

func (*ActionRaw) XXX_Merge

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

func (*ActionRaw) XXX_Size

func (m *ActionRaw) XXX_Size() int

func (*ActionRaw) XXX_Unmarshal

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

type Receipt

type Receipt struct {
	Type    ReceiptType // system defined or user defined receipt type
	Content string      // can be a raw string or a json string
}

Receipt generated when applying transaction

type ReceiptRaw

type ReceiptRaw struct {
	Type                 int32    `protobuf:"varint,1,opt,name=type,proto3" json:"type,omitempty"`
	Content              string   `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*ReceiptRaw) Descriptor

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

func (*ReceiptRaw) GetContent

func (m *ReceiptRaw) GetContent() string

func (*ReceiptRaw) GetType

func (m *ReceiptRaw) GetType() int32

func (*ReceiptRaw) Marshal

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

func (*ReceiptRaw) MarshalTo

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

func (*ReceiptRaw) ProtoMessage

func (*ReceiptRaw) ProtoMessage()

func (*ReceiptRaw) Reset

func (m *ReceiptRaw) Reset()

func (*ReceiptRaw) Size

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

func (*ReceiptRaw) String

func (m *ReceiptRaw) String() string

func (*ReceiptRaw) Unmarshal

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

func (*ReceiptRaw) XXX_DiscardUnknown

func (m *ReceiptRaw) XXX_DiscardUnknown()

func (*ReceiptRaw) XXX_Marshal

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

func (*ReceiptRaw) XXX_Merge

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

func (*ReceiptRaw) XXX_Size

func (m *ReceiptRaw) XXX_Size() int

func (*ReceiptRaw) XXX_Unmarshal

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

type ReceiptType

type ReceiptType int32

ReceiptType type of single receipt

const (
	// SystemDefined system receipt, recording info of calling a method
	SystemDefined ReceiptType = iota
	// UserDefined user defined receipt, usually a json string
	UserDefined
)

type Status

type Status struct {
	Code    StatusCode
	Message string
}

Status status of transaction execution result, including code and message

type StatusCode

type StatusCode int32

StatusCode status code of transaction execution result

const (
	Success StatusCode = iota
	ErrorGasRunOut
	ErrorBalanceNotEnough
	ErrorParamter // parameter mismatch when calling function
	ErrorRuntime  // runtime error
	ErrorTimeout
	ErrorTxFormat         // tx format errors
	ErrorDuplicateSetCode // more than one set code action in a tx
	ErrorUnknown          // other errors
)

tx execution result

type StatusRaw

type StatusRaw struct {
	Code                 int32    `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
	Message              string   `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*StatusRaw) Descriptor

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

func (*StatusRaw) GetCode

func (m *StatusRaw) GetCode() int32

func (*StatusRaw) GetMessage

func (m *StatusRaw) GetMessage() string

func (*StatusRaw) Marshal

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

func (*StatusRaw) MarshalTo

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

func (*StatusRaw) ProtoMessage

func (*StatusRaw) ProtoMessage()

func (*StatusRaw) Reset

func (m *StatusRaw) Reset()

func (*StatusRaw) Size

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

func (*StatusRaw) String

func (m *StatusRaw) String() string

func (*StatusRaw) Unmarshal

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

func (*StatusRaw) XXX_DiscardUnknown

func (m *StatusRaw) XXX_DiscardUnknown()

func (*StatusRaw) XXX_Marshal

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

func (*StatusRaw) XXX_Merge

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

func (*StatusRaw) XXX_Size

func (m *StatusRaw) XXX_Size() int

func (*StatusRaw) XXX_Unmarshal

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

type Tx

type Tx struct {
	Time       int64               `json:"time,string"`
	Expiration int64               `json:"expiration,string"`
	GasLimit   int64               `json:"gas_limit,string"`
	Actions    []*Action           `json:"-"`
	Signers    [][]byte            `json:"-"`
	Signs      []*crypto.Signature `json:"-"`
	Publisher  *crypto.Signature   `json:"-"`
	GasPrice   int64               `json:"gas_price,string"`
	// contains filtered or unexported fields
}

Tx Transaction structure

func NewTx

func NewTx(actions []*Action, signers [][]byte, gasLimit int64, gasPrice int64, expiration int64) *Tx

NewTx return a new Tx

func SignTx

func SignTx(tx *Tx, account *account.Account, signs ...*crypto.Signature) (*Tx, error)

SignTx sign the whole tx, including signers' signature, only publisher should do this

func (*Tx) Decode

func (t *Tx) Decode(b []byte) error

Decode tx from byte array

func (*Tx) Encode

func (t *Tx) Encode() []byte

Encode tx to byte array

func (*Tx) FromTxRaw

func (t *Tx) FromTxRaw(tr *TxRaw)

FromTxRaw convert tx from TxRaw

func (*Tx) Hash

func (t *Tx) Hash() []byte

Hash return cached hash if exists, or calculate with Sha3

func (*Tx) String

func (t *Tx) String() string

String return human-readable tx

func (*Tx) ToTxRaw

func (t *Tx) ToTxRaw() *TxRaw

ToTxRaw convert tx to TxRaw for transmission

func (*Tx) VerifySelf

func (t *Tx) VerifySelf() error

VerifySelf verify tx's signature

func (*Tx) VerifySigner

func (t *Tx) VerifySigner(sig *crypto.Signature) bool

VerifySigner verify signer's signature

type TxRaw

type TxRaw struct {
	Time                 int64                  `protobuf:"varint,1,opt,name=time,proto3" json:"time,omitempty"`
	Expiration           int64                  `protobuf:"varint,2,opt,name=expiration,proto3" json:"expiration,omitempty"`
	GasLimit             int64                  `protobuf:"varint,3,opt,name=gasLimit,proto3" json:"gasLimit,omitempty"`
	GasPrice             int64                  `protobuf:"varint,4,opt,name=gasPrice,proto3" json:"gasPrice,omitempty"`
	Actions              []*ActionRaw           `protobuf:"bytes,5,rep,name=actions" json:"actions,omitempty"`
	Signers              [][]byte               `protobuf:"bytes,6,rep,name=signers" json:"signers,omitempty"`
	Signs                []*crypto.SignatureRaw `protobuf:"bytes,7,rep,name=signs" json:"signs,omitempty"`
	Publisher            *crypto.SignatureRaw   `protobuf:"bytes,8,opt,name=publisher" json:"publisher,omitempty"`
	XXX_NoUnkeyedLiteral struct{}               `json:"-"`
	XXX_unrecognized     []byte                 `json:"-"`
	XXX_sizecache        int32                  `json:"-"`
}

func (*TxRaw) Descriptor

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

func (*TxRaw) GetActions

func (m *TxRaw) GetActions() []*ActionRaw

func (*TxRaw) GetExpiration

func (m *TxRaw) GetExpiration() int64

func (*TxRaw) GetGasLimit

func (m *TxRaw) GetGasLimit() int64

func (*TxRaw) GetGasPrice

func (m *TxRaw) GetGasPrice() int64

func (*TxRaw) GetPublisher

func (m *TxRaw) GetPublisher() *crypto.SignatureRaw

func (*TxRaw) GetSigners

func (m *TxRaw) GetSigners() [][]byte

func (*TxRaw) GetSigns

func (m *TxRaw) GetSigns() []*crypto.SignatureRaw

func (*TxRaw) GetTime

func (m *TxRaw) GetTime() int64

func (*TxRaw) Marshal

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

func (*TxRaw) MarshalTo

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

func (*TxRaw) ProtoMessage

func (*TxRaw) ProtoMessage()

func (*TxRaw) Reset

func (m *TxRaw) Reset()

func (*TxRaw) Size

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

func (*TxRaw) String

func (m *TxRaw) String() string

func (*TxRaw) Unmarshal

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

func (*TxRaw) XXX_DiscardUnknown

func (m *TxRaw) XXX_DiscardUnknown()

func (*TxRaw) XXX_Marshal

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

func (*TxRaw) XXX_Merge

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

func (*TxRaw) XXX_Size

func (m *TxRaw) XXX_Size() int

func (*TxRaw) XXX_Unmarshal

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

type TxReceipt

type TxReceipt struct {
	TxHash   []byte
	GasUsage int64
	/*
		CpuTimeUsage    uint64
		NetUsage    uint64
		RAMUsage    uint64
	*/
	Status        Status
	SuccActionNum int32
	Receipts      []Receipt
}

TxReceipt Transaction Receipt

func NewTxReceipt

func NewTxReceipt(txHash []byte) TxReceipt

NewTxReceipt generate tx receipt for a tx hash

func (*TxReceipt) Decode

func (r *TxReceipt) Decode(b []byte) error

Decode TxReceipt from byte array

func (*TxReceipt) Encode

func (r *TxReceipt) Encode() []byte

Encode TxReceipt as byte array

func (*TxReceipt) FromTxReceiptRaw

func (r *TxReceipt) FromTxReceiptRaw(tr *TxReceiptRaw)

FromTxReceiptRaw convert TxReceipt from proto buf data structure

func (*TxReceipt) Hash

func (r *TxReceipt) Hash() []byte

Hash return byte hash

func (*TxReceipt) String

func (r *TxReceipt) String() string

func (*TxReceipt) ToTxReceiptRaw

func (r *TxReceipt) ToTxReceiptRaw() *TxReceiptRaw

ToTxReceiptRaw convert TxReceipt to proto buf data structure

type TxReceiptRaw

type TxReceiptRaw struct {
	TxHash               []byte        `protobuf:"bytes,1,opt,name=txHash,proto3" json:"txHash,omitempty"`
	GasUsage             int64         `protobuf:"varint,2,opt,name=gasUsage,proto3" json:"gasUsage,omitempty"`
	Status               *StatusRaw    `protobuf:"bytes,3,opt,name=status" json:"status,omitempty"`
	SuccActionNum        int32         `protobuf:"varint,4,opt,name=succActionNum,proto3" json:"succActionNum,omitempty"`
	Receipts             []*ReceiptRaw `protobuf:"bytes,5,rep,name=receipts" json:"receipts,omitempty"`
	XXX_NoUnkeyedLiteral struct{}      `json:"-"`
	XXX_unrecognized     []byte        `json:"-"`
	XXX_sizecache        int32         `json:"-"`
}

func (*TxReceiptRaw) Descriptor

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

func (*TxReceiptRaw) GetGasUsage

func (m *TxReceiptRaw) GetGasUsage() int64

func (*TxReceiptRaw) GetReceipts

func (m *TxReceiptRaw) GetReceipts() []*ReceiptRaw

func (*TxReceiptRaw) GetStatus

func (m *TxReceiptRaw) GetStatus() *StatusRaw

func (*TxReceiptRaw) GetSuccActionNum

func (m *TxReceiptRaw) GetSuccActionNum() int32

func (*TxReceiptRaw) GetTxHash

func (m *TxReceiptRaw) GetTxHash() []byte

func (*TxReceiptRaw) Marshal

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

func (*TxReceiptRaw) MarshalTo

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

func (*TxReceiptRaw) ProtoMessage

func (*TxReceiptRaw) ProtoMessage()

func (*TxReceiptRaw) Reset

func (m *TxReceiptRaw) Reset()

func (*TxReceiptRaw) Size

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

func (*TxReceiptRaw) String

func (m *TxReceiptRaw) String() string

func (*TxReceiptRaw) Unmarshal

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

func (*TxReceiptRaw) XXX_DiscardUnknown

func (m *TxReceiptRaw) XXX_DiscardUnknown()

func (*TxReceiptRaw) XXX_Marshal

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

func (*TxReceiptRaw) XXX_Merge

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

func (*TxReceiptRaw) XXX_Size

func (m *TxReceiptRaw) XXX_Size() int

func (*TxReceiptRaw) XXX_Unmarshal

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

Jump to

Keyboard shortcuts

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