models

package
v0.0.0-...-5fb9e85 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2022 License: Apache-2.0 Imports: 21 Imported by: 16

Documentation

Overview

Package models

@author: xwc1125

Package models

@author: xwc1125

Package models

@author: xwc1125

Package models

@author: xwc1125

Package models

@author: xwc1125

Package models

@author: xwc1125

Package models

@author: xwc1125

Package models

@author: xwc1125

Package models

@author: xwc1125

Package models

@author: xwc1125

Package models

@author: xwc1125

Package models

@author: xwc1125

Package models

@author: xwc1125

Package models

@author: xwc1125

Index

Constants

This section is empty.

Variables

View Source
var TxStatus_name = map[uint32]string{
	0: "Unkown",
	1: "Failed",
	2: "Succeeded",
	3: "Waiting",
	4: "Pending",
}
View Source
var TxStatus_value = map[string]uint32{
	"Unkown":    0,
	"Failed":    1,
	"Succeeded": 2,
	"Waiting":   3,
	"Pending":   4,
}

Functions

func RegisterTransaction

func RegisterTransaction(txInf interface{})

RegisterTransaction 注册交易交易模型

func TxEncode

func TxEncode(tx Transaction) ([]byte, error)

TxEncode 交易编码

Types

type AccountRef

type AccountRef types.Address

AccountRef 合约对象

func (AccountRef) Address

func (ar AccountRef) Address() types.Address

Address 合约地址

type AppsStatus

type AppsStatus []TxsStatus

type Block

type Block struct {
	// contains filtered or unexported fields
}

Block 区块

func NewBlock

func NewBlock(header *Header, txs Transactions, subBlocks *Blocks) *Block

NewBlock 创建一个新的block。传入的数据都是通过深度copy进行赋值。 外部对header,txs进行修改不会影响到block block未被签名,需要进行签名

func (*Block) Block

func (b *Block) Block(hash types.Hash) *Block

func (*Block) Body

func (b *Block) Body() *Body

func (*Block) Consensus

func (b *Block) Consensus() *Consensus

func (*Block) DecodeRLP

func (b *Block) DecodeRLP(s *rlp.Stream) error

func (*Block) EncodeRLP

func (b *Block) EncodeRLP(w io.Writer) error

func (*Block) Extra

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

func (*Block) GasLimit

func (b *Block) GasLimit() uint64

func (*Block) GasUsed

func (b *Block) GasUsed() uint64

func (*Block) Hash

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

Hash 获取区块hash【已签名】

func (*Block) HashNoSign

func (b *Block) HashNoSign() types.Hash

HashNoSign 获取未签名的hash【未签名】

func (*Block) Header

func (b *Block) Header() *Header

func (*Block) Height

func (b *Block) Height() uint64

func (*Block) MarshalJSON

func (b *Block) MarshalJSON() ([]byte, error)

func (*Block) Memo

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

func (*Block) ParentHash

func (b *Block) ParentHash() types.Hash

func (*Block) SetConsensus

func (b *Block) SetConsensus(consensus *Consensus)

func (*Block) SetStateRoots

func (b *Block) SetStateRoots(stateRoots []byte)

func (*Block) SetTransactions

func (b *Block) SetTransactions(transactions Transactions)

func (*Block) Signature

func (b *Block) Signature() *signature.SignResult

func (*Block) Size

func (b *Block) Size() types.StorageSize

func (*Block) StateRoots

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

func (*Block) SubBlockCount

func (b *Block) SubBlockCount() uint64

func (*Block) SubBlockIndex

func (b *Block) SubBlockIndex() uint64

func (*Block) SubBlockRoot

func (b *Block) SubBlockRoot() types.Hash

func (*Block) SubBlocks

func (b *Block) SubBlocks() *Blocks

func (*Block) Timestamp

func (b *Block) Timestamp() uint64

func (*Block) Transaction

func (b *Block) Transaction(hash types.Hash) Transaction

Transaction 根据hash从block的交易中获取交易对象

func (*Block) Transactions

func (b *Block) Transactions() Transactions

func (*Block) TxsCount

func (b *Block) TxsCount() uint64

func (*Block) TxsRoot

func (b *Block) TxsRoot() []types.Hash

func (*Block) UnmarshalJSON

func (b *Block) UnmarshalJSON(input []byte) error

func (*Block) WithSeal

func (b *Block) WithSeal(header *Header) *Block

WithSeal 创建一个新的block,新的block使用传入的header替换,txs使用对象的。 被consensus seal

type BlockAbstract

type BlockAbstract struct {
	Hash   types.Hash
	Height uint64
}

BlockAbstract 区块的摘要

type BlockchainLocalConfig

type BlockchainLocalConfig struct {
	Metrics      bool   `json:"metrics" mapstructure:"metrics"`             // 是否显示指标
	MetricsLevel uint64 `json:"metrics_level" mapstructure:"metrics_level"` // 指标级别
}

BlockchainLocalConfig blockchain配置

func (BlockchainLocalConfig) IsMetrics

func (c BlockchainLocalConfig) IsMetrics(_metricsLevel uint64) bool

type Blocks

type Blocks struct {
	// contains filtered or unexported fields
}

Blocks 交易集合

func NewBlocks

func NewBlocks(blocks []*Block) *Blocks

func (*Blocks) BlocksRoot

func (bs *Blocks) BlocksRoot() types.Hash

func (*Blocks) Data

func (bs *Blocks) Data() []*Block

func (*Blocks) DecodeRLP

func (bs *Blocks) DecodeRLP(s *rlp.Stream) error

func (*Blocks) DeepCopy

func (bs *Blocks) DeepCopy() *Blocks

func (*Blocks) EncodeRLP

func (bs *Blocks) EncodeRLP(w io.Writer) error

func (*Blocks) Get

func (bs *Blocks) Get(i int) *Block

func (*Blocks) Hashes

func (bs *Blocks) Hashes() []string

func (*Blocks) Item

func (bs *Blocks) Item(i int) []byte

func (*Blocks) Key

func (bs *Blocks) Key(i int) []byte

func (*Blocks) Len

func (bs *Blocks) Len() int

func (*Blocks) Less

func (bs *Blocks) Less(i, j int) bool

func (*Blocks) Swap

func (bs *Blocks) Swap(i, j int)

type Body

type Body struct {
	Height uint64       `json:"height"`       // 区块高度
	Txs    Transactions `json:"transactions"` // 交易集合
}

Body 区块交易集合[可变的、不安全的]

type BroadcasterLocalConfig

type BroadcasterLocalConfig struct {
	Metrics      bool   `json:"metrics" mapstructure:"metrics"`             // 是否显示指标
	MetricsLevel uint64 `json:"metrics_level" mapstructure:"metrics_level"` // 指标级别
}

BroadcasterLocalConfig 广播的配置

func (BroadcasterLocalConfig) IsMetrics

func (c BroadcasterLocalConfig) IsMetrics(_metricsLevel uint64) bool

type ChainConfig

type ChainConfig struct {
	ChainID     uint64 `json:"chain_id" mapstructure:"chain_id"`         // 链ID
	ChainName   string `json:"chain_name" mapstructure:"chain_name"`     // 链名称,Chain5j
	VersionName string `json:"version_name" mapstructure:"version_name"` // 版本名称,v1.0.0
	VersionCode uint64 `json:"version_code" mapstructure:"version_code"` // 版本code,1

	GenesisHeight uint64 `json:"genesis_height" mapstructure:"genesis_height"` // 创世高度
	TxSizeLimit   uint64 `json:"tx_size_limit" mapstructure:"tx_size_limit"`   // 单笔交易最大限制 单位 KB

	Packer *PackerConfig `json:"packer" mapstructure:"packer" rlp:"nil"` // 打包逻辑处理
	// TODO 【xwc1125】需要将共识配置设置成map的方式。在每个共识内部自己去解析
	Consensus *ConsensusConfig `json:"consensus,omitempty" mapstructure:"consensus" rlp:"nil"`
	StateApp  *StateAppConfig  `json:"state_app,omitempty" mapstructure:"state_app" rlp:"nil"`
}

ChainConfig 链配置

type Consensus

type Consensus struct {
	Name      string `json:"name,omitempty"`                 // 共识名称
	Consensus []byte `json:"consensus,omitempty" rlp:"tail"` // 共识内容
}

Consensus 共识信息

func (*Consensus) Copy

func (c *Consensus) Copy() *Consensus

Copy 拷贝

func (*Consensus) MarshalJSON

func (c *Consensus) MarshalJSON() ([]byte, error)

func (*Consensus) UnmarshalJSON

func (c *Consensus) UnmarshalJSON(input []byte) error

type ConsensusConfig

type ConsensusConfig struct {
	Name string           `json:"name,omitempty"`      // 共识名称
	Data *hashmap.HashMap `json:"consensus,omitempty"` // 共识具体配置
}

func (*ConsensusConfig) ToConsensus

func (c *ConsensusConfig) ToConsensus() (*Consensus, error)

type ConsensusHandler

type ConsensusHandler struct {
	Method  string
	Message []byte
	Block   *Block
}

type ConsensusLocalConfig

type ConsensusLocalConfig struct {
	Metrics      bool   `json:"metrics" mapstructure:"metrics"`             // 是否显示指标
	MetricsLevel uint64 `json:"metrics_level" mapstructure:"metrics_level"` // 指标级别
}

ConsensusLocalConfig consensus配置

func (ConsensusLocalConfig) IsMetrics

func (c ConsensusLocalConfig) IsMetrics(_metricsLevel uint64) bool

type DatabaseConfig

type DatabaseConfig struct {
	Driver       string `json:"driver" mapstructure:"driver"`               // 驱动类型
	Source       string `json:"source" mapstructure:"source"`               // 资源
	Username     string `json:"username" mapstructure:"username"`           // 用户名
	Password     string `json:"password" mapstructure:"password"`           // 密码
	Metrics      bool   `json:"metrics" mapstructure:"metrics"`             // 是否显示指标
	MetricsLevel uint64 `json:"metrics_level" mapstructure:"metrics_level"` // 指标级别
}

func (DatabaseConfig) IsMetrics

func (c DatabaseConfig) IsMetrics(_metricsLevel uint64) bool

type Genesis

type Genesis struct {
	ChainConfig     *ChainConfig        `json:"config" mapstructure:"config"`                               // 链配置
	ConsensusConfig *ConsensusConfig    `json:"consensus_config,omitempty" mapstructure:"consensus_config"` // 共识配置
	GenesisBlock    *GenesisBlock       `json:"genesis_block,omitempty" mapstructure:"genesis_block"`       // 创世区块
	AccountAlloc    GenesisAccountAlloc `json:"account_alloc,omitempty" mapstructure:"account_alloc"`       // 账户配置
	AddressAlloc    GenesisAddressAlloc `json:"address_alloc,omitempty" mapstructure:"address_alloc"`       // 地址配置
}

Genesis 创世文件内容,此文件用于生成genesis.json 在进行sign_genesis时,需要将ConsensusConfig转换为chainConfig中的Consensus 将GenesisBlock转换为chainConfig中的GenesisBlock 将AccountAlloc,AddressAlloc转换为txs

type GenesisAccountAlloc

type GenesisAccountAlloc map[string]accounts.AccountStore

GenesisAccountAlloc account ==> accounts.AccountStore

type GenesisAddress

type GenesisAddress struct {
	Code    *hexutil.Bytes            `json:"code,omitempty" mapstructure:"code"`       // code
	Storage map[types.Hash]types.Hash `json:"storage,omitempty" mapstructure:"storage"` // 存储
	Balance *big.Int                  `json:"balance,omitempty" mapstructure:"balance"` // 余额
	Nonce   uint64                    `json:"nonce,omitempty" mapstructure:"nonce"`     // nonce
}

GenesisAddress 创世地址信息

type GenesisAddressAlloc

type GenesisAddressAlloc map[types.Address]GenesisAddress

GenesisAddressAlloc address ==> GenesisAddress

type GenesisBlock

type GenesisBlock struct {
	ParentHash   types.Hash          `json:"parent_hash,omitempty"`
	Height       uint64              `json:"height,omitempty"`
	StateRoots   hexutil.Bytes       `json:"state_roots,omitempty"`
	TxsRoot      []types.Hash        `json:"txs_root,omitempty"`
	TxsCount     uint64              `json:"txs_count,omitempty"`
	Timestamp    uint64              `json:"timestamp,omitempty"`
	GasUsed      uint64              `json:"gas_used,omitempty"`
	GasLimit     uint64              `json:"gas_limit,omitempty"`
	Consensus    *Consensus          `json:"consensus,omitempty"`
	ArchiveHash  *types.Hash         `json:"archive_hash,omitempty"`
	ReceiptsRoot []types.Hash        `json:"receipts_root,omitempty"` // 交易收据的hash
	LogsBloom    *statetype.Bloom    `json:"logs_bloom,omitempty"`    // logs的bloom
	Extra        hexutil.Bytes       `json:"extra,omitempty"`
	Signature    *crypto2.SignResult `json:"signature,omitempty"`
}

GenesisBlock 创世文件中区块的配置

type GenesisExtra

type GenesisExtra struct {
	RawExtra     []byte `json:"raw_extra"`     // 原始扩展内容
	GenesisBytes []byte `json:"genesis_bytes"` // 创世文件内容
}

GenesisExtra 创世区块的扩展内容。此内容在创世块中,填充区块的Extra

type HandshakeMsg

type HandshakeMsg struct {
	Peer               P2PID      `json:"peer" rlp:"-"`         // 节点ID
	ProtocolVersion    uint32     `json:"protocol_version"`     // 协议版本
	NetworkId          uint64     `json:"network_id"`           // 网络ID
	CurrentBlockHash   types.Hash `json:"current_block_hash"`   // 当前区块hash
	CurrentBlockHeight uint64     `json:"current_block_height"` // 当前区块高度
	GenesisBlockHash   types.Hash `json:"genesis_block_hash"`   // 创世块hash
}

HandshakeMsg 握手消息

type Header struct {
	ParentHash types.Hash `json:"parent_hash"` // 父Hash
	Height     uint64     `json:"height"`      // 区块高度
	Timestamp  uint64     `json:"timestamp"`   // 区块时间戳[毫秒]
	StateRoots []byte     `json:"state_roots"` // 状态根

	// 子区块内容
	SubBlockIndex uint64     `json:"sub_block_index"`           // 子区块顺序
	SubBlockRoot  types.Hash `json:"sub_block_root,omitempty"`  // 子区块根
	SubBlockCount uint64     `json:"sub_block_count,omitempty"` // 子区块个数

	// 交易内容
	TxsRoot      []types.Hash     `json:"txs_root"`                       // 交易树根数组(多种交易类型,存在多种交易根)
	TxsCount     uint64           `json:"txs_count"`                      // 交易个数
	ReceiptsRoot []types.Hash     `json:"receipts_root,omitempty"`        // 交易收据根
	LogsBloom    *statetype.Bloom `json:"logs_bloom,omitempty" rlp:"nil"` // logs的bloom

	// gas消耗内容
	GasUsed   uint64     `json:"gas_used"`                      // 总的区块消耗gas
	GasLimit  uint64     `json:"gas_limit"`                     // 区块最大gas
	Consensus *Consensus `json:"consensus,omitempty" rlp:"nil"` // 共识内容

	ArchiveHash *types.Hash           `json:"archive_hash,omitempty" rlp:"nil"` // 区块归档区块hash
	Extra       []byte                `json:"extra,omitempty"`                  // 扩展内容
	Memo        []byte                `json:"memo,omitempty"`                   // 备忘录
	Signature   *signature.SignResult `json:"signature" rlp:"nil"`              // 签名数据
}

Header 区块header

func CopyHeader

func CopyHeader(h *Header) *Header

CopyHeader 创建header的深拷贝,避免副作用修改header的值

func (*Header) Copy

func (h *Header) Copy() *Header

Copy 拷贝

func (*Header) Hash

func (h *Header) Hash() types.Hash

Hash 区块头hash

func (*Header) HashNoSign

func (h *Header) HashNoSign() types.Hash

HashNoSign 未签名的hash,用于需要签名时的处理

func (Header) MarshalJSON

func (h Header) MarshalJSON() ([]byte, error)

MarshalJSON json序列化

func (*Header) UnmarshalJSON

func (h *Header) UnmarshalJSON(input []byte) error

UnmarshalJSON json反序列化

type LocalConfig

type LocalConfig struct {
	Log         logger.LogConfig       `json:"log" mapstructure:"log"`                 // 日志配置
	Database    DatabaseConfig         `json:"database" mapstructure:"database"`       // database配置
	Blockchain  BlockchainLocalConfig  `json:"blockchain" mapstructure:"blockchain"`   // blockchain配置
	Packer      PackerLocalConfig      `json:"packer" mapstructure:"packer"`           // packer配置
	TxPool      TxPoolLocalConfig      `json:"tx_pool" mapstructure:"tx_pool"`         // 交易池配置
	NodeKey     NodeKeyLocalConfig     `json:"node_key" mapstructure:"node_key"`       // nodekey模块配置
	Broadcaster BroadcasterLocalConfig `json:"broadcaster" mapstructure:"broadcaster"` // broadcaster模块配置
	P2P         P2PConfig              `json:"p2p" mapstructure:"p2p"`                 // p2p模块配置
	Consensus   ConsensusLocalConfig   `json:"consensus" mapstructure:"consensus"`     // consensus模块配置
}

LocalConfig 节点启动本地配置

type Message

type Message struct {
	// contains filtered or unexported fields
}

func NewEvmMessage

func NewEvmMessage(from types.Address, to *types.Address, nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, checkNonce bool) Message

func (Message) CheckNonce

func (m Message) CheckNonce() bool

func (Message) From

func (m Message) From() string

func (Message) GasLimit

func (m Message) GasLimit() uint64

func (Message) GasPrice

func (m Message) GasPrice() *big.Int

func (Message) Input

func (m Message) Input() []byte

func (*Message) MarshalJSON

func (m *Message) MarshalJSON() ([]byte, error)

func (Message) Nonce

func (m Message) Nonce() uint64

func (Message) SetPrice

func (m Message) SetPrice(gasPrice *big.Int)

func (Message) SetValue

func (m Message) SetValue(value *big.Int)

func (Message) To

func (m Message) To() string

func (*Message) UnmarshalJSON

func (m *Message) UnmarshalJSON(input []byte) error

func (Message) Value

func (m Message) Value() *big.Int

type MsgReadWriter

type MsgReadWriter interface {
	MsgReader
	MsgWriter
}

MsgReadWriter 消息读写

type MsgReader

type MsgReader interface {
	ReadMsg() (*P2PMessage, error)
}

MsgReader 消息读

type MsgWriter

type MsgWriter interface {
	// WriteMsg 发送消息是堵塞的,必须对方已消费。[消息只能发送一次]
	WriteMsg(msg *P2PMessage) error
}

MsgWriter 消息写

type NodeID

type NodeID string

NodeID 节点签名的地址(用于区块签名)

func NodeIdFromString

func NodeIdFromString(base58Id string) (NodeID, error)

func (*NodeID) DecodeRLP

func (id *NodeID) DecodeRLP(s *rlp.Stream) error

func (*NodeID) EncodeRLP

func (id *NodeID) EncodeRLP(w io.Writer) error

func (NodeID) String

func (id NodeID) String() string

type NodeKeyLocalConfig

type NodeKeyLocalConfig struct {
	// 节点私钥模块参数属性定义
	FileType     string `json:"file_type" mapstructure:"file_type"`         // 文件类型
	PrvKeyFile   string `json:"prv_key_file" mapstructure:"prv_key_file"`   // 私钥文件
	PubKeyFile   string `json:"pub_key_file" mapstructure:"pub_key_file"`   // 公钥文件
	Password     string `json:"password" mapstructure:"password"`           // 密码
	Metrics      bool   `json:"metrics" mapstructure:"metrics"`             // 是否显示指标
	MetricsLevel uint64 `json:"metrics_level" mapstructure:"metrics_level"` // 指标级别
}

NodeKeyLocalConfig nodeKey模块参数配置

func (NodeKeyLocalConfig) IsMetrics

func (c NodeKeyLocalConfig) IsMetrics(_metricsLevel uint64) bool

type P2PConfig

type P2PConfig struct {
	Host string `json:"host" mapstructure:"host"` // host
	Port int    `json:"port" mapstructure:"port"` // 端口号

	KeyPath  string `json:"key_path" mapstructure:"key_path"`   // 私钥路径
	CertPath string `json:"cert_path" mapstructure:"cert_path"` // 证书路径
	IsTls    bool   `json:"is_tls" mapstructure:"is_tls"`       // 安全P2P

	EnablePermission bool     `json:"enable_permission" mapstructure:"enable_permission"` // 权限校验
	MaxPeers         int32    `json:"max_peers" mapstructure:"max_peers"`                 // 最大peer个数
	StaticNodes      []string `json:"static_nodes" mapstructure:"static_nodes"`           // 静态节点.peerID-->p2p.ID
	CaRoots          []string `json:"ca_roots" mapstructure:"ca_roots"`                   // Ca证书

	Metrics      bool   `json:"metrics" mapstructure:"metrics"`             // 是否显示指标
	MetricsLevel uint64 `json:"metrics_level" mapstructure:"metrics_level"` // 指标级别
}

P2PConfig p2p配置

func (P2PConfig) IsMetrics

func (c P2PConfig) IsMetrics(_metricsLevel uint64) bool

type P2PID

type P2PID string

P2PID p2p的ID(用于p2p)

func IDFromString

func IDFromString(base58Id string) (P2PID, error)

IDFromString id为pretty

func (*P2PID) DecodeRLP

func (id *P2PID) DecodeRLP(s *rlp.Stream) error

func (*P2PID) EncodeRLP

func (id *P2PID) EncodeRLP(w io.Writer) error

func (P2PID) String

func (id P2PID) String() string

String 节点ID的string

type P2PInfo

type P2PInfo struct {
	Id        P2PID  `json:"id"`        // 节点ID
	NetUrl    string `json:"net_url"`   // 网络url
	Connected bool   `json:"connected"` // 是否连接
}

P2PInfo 节点信息

type P2PMessage

type P2PMessage struct {
	Type uint   `json:"type"` // 类型
	Peer P2PID  `json:"peer"` // 节点ID
	Data []byte `json:"data"` // 数据
}

P2PMessage P2P消息

type P2PType

type P2PType = uint
const (
	TransactionSend  P2PType  = iota // 交易发送
	BlockMsg                         // 区块信息
	ConsensusMsg                     // 共识信息
	MsgTypeHandshake = 0x9999        // 握手消息
)

type PackerConfig

type PackerConfig struct {
	WorkerType           WorkerType `json:"worker_type" mapstructure:"worker_type"`                         // 出块类型
	BlockMaxTxsCapacity  uint64     `json:"block_max_txs_capacity" mapstructure:"block_max_txs_capacity"`   // 每个区块的交易最大个数
	BlockMaxSize         uint64     `json:"block_max_size" mapstructure:"block_max_size"`                   // 区块最大size(kb)
	BlockMaxIntervalTime uint64     `json:"block_max_interval_time" mapstructure:"block_max_interval_time"` // 最大出块间隔(ms)[=0时,采用交易触发]
	BlockGasLimit        uint64     `json:"block_gas_limit" mapstructure:"block_gas_limit"`                 // 区块的最大gas
	Period               uint64     `json:"period" mapstructure:"period"`                                   // 定时出块(=0时,采用交易触发)【毫秒】
	EmptyBlocks          uint64     `json:"empty_blocks" mapstructure:"empty_blocks"`                       // 空块的个数
	Timeout              uint64     `json:"timeout" mapstructure:"timeout"`                                 // 超时时间【毫秒】
	MatchTxsCapacity     bool       `json:"match_txs_capacity" yaml:"match_txs_capacity"`                   // 是否满足最大txs才开始打包
}

PackerConfig 打包器的配置

type PackerLocalConfig

type PackerLocalConfig struct {
	Metrics      bool   `json:"metrics" mapstructure:"metrics"`             // 是否显示指标
	MetricsLevel uint64 `json:"metrics_level" mapstructure:"metrics_level"` // 指标级别
}

PackerLocalConfig 打包器配置

func (PackerLocalConfig) IsMetrics

func (c PackerLocalConfig) IsMetrics(_metricsLevel uint64) bool

type StateAppConfig

type StateAppConfig struct {
	UseEthereum bool `json:"use_eth"` // 是否使用eth
}

StateAppConfig 状态应用配置

type StateTransaction

type StateTransaction interface {
	Transaction

	From() string                   // 发送者
	To() string                     // 接收者
	GasLimit() uint64               // gasLimit
	Value() *big.Int                // value
	Input() []byte                  // 合约请求的数据
	GasPrice() uint64               // gasPrice
	Nonce() uint64                  // 唯一码
	Signer() (types.Address, error) // 签名者
	Cost() *big.Int                 // 预估balance消耗

}

StateTransaction 状态交易

type SyncingStatus

type SyncingStatus struct {
	IsSync        bool         `json:"is_sync"`        // true:同步中,false:未同步
	StartingBlock *hexutil.Big `json:"starting_block"` // 开始块
	CurrentBlock  *hexutil.Big `json:"current_block"`  // 当前块
	HighestBlock  *hexutil.Big `json:"highest_block"`  // 目标最高块
}

SyncingStatus 同步状态

type Transaction

type Transaction interface {
	TxType() types.TxType      // 交易类型
	ChainId() string           // 链ID
	Hash() types.Hash          // 交易Hash
	Less(tx2 Transaction) bool // 是否小于tx2.用于交易排序
	Size() types.StorageSize   // 交易大小
	codec.Serializer           // 交易序列化
	codec.Deserializer         // 交易反序列化

}

Transaction 交易接口

func NewTransaction

func NewTransaction(t types.TxType) (Transaction, error)

NewTransaction 创建一个新的交易对象

func TxDecode

func TxDecode(bytes []byte) (Transaction, error)

TxDecode 交易解码

type TransactionSortedList

type TransactionSortedList []Transaction

TransactionSortedList nonce递增排序,price递减排序

func NewTransactionSortedList

func NewTransactionSortedList(txs []Transaction) TransactionSortedList

func (TransactionSortedList) Hashes

func (txList TransactionSortedList) Hashes() []types.Hash

func (TransactionSortedList) Item

func (txList TransactionSortedList) Item(i int) []byte

func (TransactionSortedList) Key

func (txList TransactionSortedList) Key(i int) []byte

func (TransactionSortedList) Len

func (txList TransactionSortedList) Len() int

func (TransactionSortedList) Less

func (txList TransactionSortedList) Less(i, j int) bool

func (TransactionSortedList) Swap

func (txList TransactionSortedList) Swap(i, j int)

type Transactions

type Transactions []TransactionSortedList

Transactions 交易集合

func NewTransactions

func NewTransactions(txs []TransactionSortedList) Transactions

NewTransactions 创建一个新的交易集合

func (Transactions) Add

func (txs Transactions) Add(tx Transaction)

Add 添加单笔交易

func (Transactions) AllLen

func (txs Transactions) AllLen() int

func (Transactions) Data

func (txs Transactions) Data() []TransactionSortedList

Data 交易集合的交易数组

func (*Transactions) DecodeRLP

func (txs *Transactions) DecodeRLP(s *rlp.Stream) error

DecodeRLP rlp解码

func (Transactions) DeepCopy

func (txs Transactions) DeepCopy() Transactions

DeepCopy 交易集合深度拷贝

func (Transactions) EncodeRLP

func (txs Transactions) EncodeRLP(w io.Writer) error

EncodeRLP rlp编码

func (Transactions) GetTx

func (txs Transactions) GetTx(txType types.TxType, i uint) Transaction

GetTx 获取交易集合中指定位置的交易

func (Transactions) Hashes

func (txs Transactions) Hashes() map[types.TxType][]types.Hash

Hashes 交易集合的hash集

func (Transactions) Len

func (txs Transactions) Len() int

func (Transactions) Less

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

func (Transactions) Print

func (txs Transactions) Print() string

func (Transactions) Swap

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

func (Transactions) TxsRoot

func (txs Transactions) TxsRoot() []types.Hash

TxsRoot 所有交易的hash

type TxPoolLocalConfig

type TxPoolLocalConfig struct {
	Capacity     uint64 `json:"capacity" mapstructure:"capacity"`           // 交易池的容量
	CacheDir     string `json:"cache_dir" mapstructure:"cache_dir"`         // 交易池的持久化目录
	Metrics      bool   `json:"metrics" mapstructure:"metrics"`             // 是否显示指标
	MetricsLevel uint64 `json:"metrics_level" mapstructure:"metrics_level"` // 指标级别
}

TxPoolLocalConfig 交易池配置

func (TxPoolLocalConfig) IsMetrics

func (c TxPoolLocalConfig) IsMetrics(_metricsLevel uint64) bool

type TxStatus

type TxStatus uint32

TxStatus 交易状态

const (
	TxStatus_Unkown    TxStatus = 0 // 未知
	TxStatus_Failed    TxStatus = 1 // 失败
	TxStatus_Succeeded TxStatus = 2 // 成功
	TxStatus_Waiting   TxStatus = 3 // 等待中
	TxStatus_Pending   TxStatus = 4 // 提交中
)

type TxsStatus

type TxsStatus struct {
	TxType     types.TxType          `json:"tx_type"`
	StateRoots []byte                `json:"state_roots"`
	GasUsed    uint64                `json:"gas_used"`
	OkTxs      TransactionSortedList `json:"ok_txs"`
	ErrTxs     TransactionSortedList `json:"err_txs"`
}

TxsStatus 交易集状态

type VmMessage

type VmMessage interface {
	From() string       // 发送者
	To() string         // 接收者
	Nonce() uint64      // 唯一码
	GasLimit() uint64   // gasLimit
	GasPrice() *big.Int // gasPrice
	Value() *big.Int    // value
	Input() []byte      // 合约请求的数据
	CheckNonce() bool   // 是否检测nonce
}

VmMessage 合约调用对象

func TxAsVmMessage

func TxAsVmMessage(tx StateTransaction) (VmMessage, error)

TxAsVmMessage 将transaction转换为vmMessage

type WorkerType

type WorkerType uint64
const (
	Timing             WorkerType = iota // 定时出块
	TransactionTrigger                   // 交易触发,无空块
	BlockStack                           // 定量空块
)

Directories

Path Synopsis
Package accounts @author: xwc1125 Package accounts @author: xwc1125
Package accounts @author: xwc1125 Package accounts @author: xwc1125
Package eventtype @author: xwc1125
Package eventtype @author: xwc1125
Package ext external data @author: xwc1125
Package ext external data @author: xwc1125
Package permission @author: xwc1125 Package permission @author: xwc1125 Package permission @author: xwc1125
Package permission @author: xwc1125 Package permission @author: xwc1125 Package permission @author: xwc1125
Package statetype @author: xwc1125 Package statetype @author: xwc1125 Package statetype @author: xwc1125 Package statetype @author: xwc1125 Package statetype @author: xwc1125
Package statetype @author: xwc1125 Package statetype @author: xwc1125 Package statetype @author: xwc1125 Package statetype @author: xwc1125 Package statetype @author: xwc1125
Package vm @author: xwc1125 Package vm @author: xwc1125 Package vm @author: xwc1125 Package vm @author: xwc1125 Package vm @author: xwc1125 Package vm @author: xwc1125
Package vm @author: xwc1125 Package vm @author: xwc1125 Package vm @author: xwc1125 Package vm @author: xwc1125 Package vm @author: xwc1125 Package vm @author: xwc1125

Jump to

Keyboard shortcuts

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