types

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: May 27, 2022 License: MIT Imports: 8 Imported by: 28

Documentation

Index

Constants

View Source
const (
	HashTypeData  ScriptHashType = "data"
	HashTypeData1 ScriptHashType = "data1"
	HashTypeType  ScriptHashType = "type"

	DepTypeCode     DepType = "code"
	DepTypeDepGroup DepType = "dep_group"

	TransactionStatusPending   TransactionStatus = "pending"
	TransactionStatusProposed  TransactionStatus = "proposed"
	TransactionStatusCommitted TransactionStatus = "committed"
	TransactionStatusUnknown   TransactionStatus = "unknown"
	TransactionStatusRejected  TransactionStatus = "rejected"
)
View Source
const (
	HashLength = 32
)

Variables

This section is empty.

Functions

func SerializeArray

func SerializeArray(items []Serializer) ([][]byte, error)

SerializeArray serialize array

func SerializeBytes

func SerializeBytes(items []byte) []byte

SerializeFixVec serialize bytes There are two steps of serializing a bytes:

Serialize the length as a 32 bit unsigned integer in little-endian.
Serialize all items in it.

func SerializeDynVec

func SerializeDynVec(items [][]byte) []byte

SerializeDynVec serialize dynvec There are three steps of serializing a dynvec:

Serialize the full size in bytes as a 32 bit unsigned integer in little-endian.
Serialize all offset of items as 32 bit unsigned integer in little-endian.
Serialize all items in it.

func SerializeFixVec

func SerializeFixVec(items [][]byte) []byte

SerializeFixVec serialize fixvec vector There are two steps of serializing a fixvec:

Serialize the length as a 32 bit unsigned integer in little-endian.
Serialize all items in it.

func SerializeHashType added in v0.101.1

func SerializeHashType(hashType ScriptHashType) (string, error)

func SerializeOption

func SerializeOption(o Serializer) ([]byte, error)

SerializeOption serialize option

func SerializeOptionBytes

func SerializeOptionBytes(o []byte) ([]byte, error)

SerializeOption serialize option

func SerializeStruct

func SerializeStruct(fields [][]byte) []byte

SerializeStruct serialize struct

func SerializeTable

func SerializeTable(fields [][]byte) []byte

SerializeTable serialize table The serializing steps are same as table:

Serialize the full size in bytes as a 32 bit unsigned integer in little-endian.
Serialize all offset of fields as 32 bit unsigned integer in little-endian.
Serialize all fields in it in the order they are declared.

func SerializeUint

func SerializeUint(n uint) []byte

func SerializeUint64

func SerializeUint64(n uint64) []byte

Types

type AlertMessage

type AlertMessage struct {
	Id          string `json:"id"`
	Message     string `json:"message"`
	NoticeUntil uint64 `json:"notice_until"`
	Priority    string `json:"priority"`
}

type BannedAddress

type BannedAddress struct {
	Address   string `json:"address"`
	BanReason string `json:"ban_reason"`
	BanUntil  uint64 `json:"ban_until"`
	CreatedAt uint64 `json:"created_at"`
}

type BatchLiveCellItem added in v0.2.0

type BatchLiveCellItem struct {
	OutPoint OutPoint
	WithData bool
	Result   *CellWithStatus
	Error    error
}

type BatchTransactionItem

type BatchTransactionItem struct {
	Hash   Hash
	Result *TransactionWithStatus
	Error  error
}

refer BatchElem from go-ethereum

type Block

type Block struct {
	Header       *Header        `json:"header"`
	Proposals    []string       `json:"proposals"`
	Transactions []*Transaction `json:"transactions"`
	Uncles       []*UncleBlock  `json:"uncles"`
}

type BlockEconomicState added in v0.3.0

type BlockEconomicState struct {
	Issuance    BlockIssuance `json:"issuance"`
	MinerReward MinerReward   `json:"miner_reward"`
	TxsFee      *big.Int      `json:"txs_fee"`
	FinalizedAt Hash          `json:"finalized_at"`
}

type BlockIssuance added in v0.3.0

type BlockIssuance struct {
	Primary   *big.Int `json:"primary"`
	Secondary *big.Int `json:"secondary"`
}

type BlockReward

type BlockReward struct {
	Primary        *big.Int `json:"primary"`
	ProposalReward *big.Int `json:"proposal_reward"`
	Secondary      *big.Int `json:"secondary"`
	Total          *big.Int `json:"total"`
	TxFee          *big.Int `json:"tx_fee"`
}

type BlockchainInfo

type BlockchainInfo struct {
	Alerts                 []*AlertMessage `json:"alerts"`
	Chain                  string          `json:"chain"`
	Difficulty             *big.Int        `json:"difficulty"`
	Epoch                  uint64          `json:"epoch"`
	IsInitialBlockDownload bool            `json:"is_initial_block_download"`
	MedianTime             uint64          `json:"median_time"`
}

type Cell

type Cell struct {
	BlockHash     Hash      `json:"block_hash"`
	Capacity      uint64    `json:"capacity"`
	Lock          *Script   `json:"lock"`
	OutPoint      *OutPoint `json:"out_point"`
	Type          *Script   `json:"type"`
	Cellbase      bool      `json:"cellbase,omitempty"`
	OutputDataLen uint64    `json:"output_data_len,omitempty"`
}

type CellData

type CellData struct {
	Content []byte `json:"content"`
	Hash    Hash   `json:"hash"`
}

type CellDep

type CellDep struct {
	OutPoint *OutPoint `json:"out_point"`
	DepType  DepType   `json:"dep_type"`
}

func (*CellDep) Serialize

func (d *CellDep) Serialize() ([]byte, error)

Serialize cell dep

type CellInfo

type CellInfo struct {
	Data   *CellData   `json:"data"`
	Output *CellOutput `json:"output"`
}

type CellInput

type CellInput struct {
	Since          uint64    `json:"since"`
	PreviousOutput *OutPoint `json:"previous_output"`
}

func (*CellInput) Serialize

func (i *CellInput) Serialize() ([]byte, error)

Serialize cell input

type CellOutput

type CellOutput struct {
	Capacity uint64  `json:"capacity"`
	Lock     *Script `json:"lock"`
	Type     *Script `json:"type"`
}

func (CellOutput) OccupiedCapacity added in v0.2.0

func (o CellOutput) OccupiedCapacity(outputData []byte) uint64

func (*CellOutput) Serialize

func (o *CellOutput) Serialize() ([]byte, error)

Serialize cell output

type CellTransaction

type CellTransaction struct {
	ConsumedBy *TransactionPoint `json:"consumed_by"`
	CreatedBy  *TransactionPoint `json:"created_by"`
}

type CellWithStatus

type CellWithStatus struct {
	Cell   *CellInfo `json:"cell"`
	Status string    `json:"status"`
}

type Consensus added in v0.41.0

type Consensus struct {
	Id                                   string         `json:"ID"`
	GenesisHash                          Hash           `json:"genesis_hash"`
	DaoTypeHash                          Hash           `json:"dao_type_hash"`
	Secp256k1Blake160SighashAllTypeHash  Hash           `json:"secp256k1_blake160_sighash_all_type_hash"`
	Secp256k1Blake160MultisigAllTypeHash Hash           `json:"secp256k1_blake160_multisig_all_type_hash"`
	InitialPrimaryEpochReward            uint64         `json:"initial_primary_epoch_reward"`
	SecondaryEpochReward                 uint64         `json:"secondary_epoch_reward"`
	MaxUnclesNum                         uint64         `json:"max_uncles_num"`
	OrphanRateTarget                     RationalU256   `json:"orphan_rate_target"`
	EpochDurationTarget                  uint64         `json:"epoch_duration_target"`
	TxProposalWindow                     ProposalWindow `json:"tx_proposal_window"`
	ProposerRewardRatio                  RationalU256   `json:"proposer_reward_ratio"`
	CellbaseMaturity                     uint64         `json:"cellbase_maturity"`
	MedianTimeBlockCount                 uint64         `json:"median_time_block_count"`
	MaxBlockCycles                       uint64         `json:"max_block_cycles"`
	BlockVersion                         uint           `json:"block_version"`
	TxVersion                            uint           `json:"tx_version"`
	TypeIdCodeHash                       Hash           `json:"type_id_code_hash"`
	MaxBlockProposalsLimit               uint64         `json:"max_block_proposals_limit"`
	PrimaryEpochRewardHalvingInterval    uint64         `json:"primary_epoch_reward_halving_interval"`
	PermanentDifficultyInDummy           bool           `json:"permanent_difficulty_in_dummy"`
}

type DepType

type DepType string

func (DepType) Serialize

func (t DepType) Serialize() ([]byte, error)

Serialize dep type

type DryRunTransactionResult

type DryRunTransactionResult struct {
	Cycles uint64 `json:"cycles"`
}

type Epoch

type Epoch struct {
	CompactTarget uint64 `json:"compact_target"`
	Length        uint64 `json:"length"`
	Number        uint64 `json:"number"`
	StartNumber   uint64 `json:"start_number"`
}

type EpochParams

type EpochParams struct {
	Length uint64
	Index  uint64
	Number uint64
}

func ParseEpoch

func ParseEpoch(epoch uint64) *EpochParams

func (*EpochParams) Uint64

func (ep *EpochParams) Uint64() uint64

type EstimateFeeRateResult

type EstimateFeeRateResult struct {
	FeeRate uint64 `json:"fee_rate"`
}

type Hash

type Hash [HashLength]byte

func BytesToHash

func BytesToHash(b []byte) Hash

func HexToHash

func HexToHash(s string) Hash

func (Hash) Bytes

func (h Hash) Bytes() []byte

func (Hash) Hex

func (h Hash) Hex() string

func (Hash) MarshalText

func (h Hash) MarshalText() ([]byte, error)

func (Hash) Serialize

func (h Hash) Serialize() ([]byte, error)

func (*Hash) SetBytes

func (h *Hash) SetBytes(b []byte)

func (Hash) String

func (h Hash) String() string

func (*Hash) UnmarshalJSON

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

func (*Hash) UnmarshalText

func (h *Hash) UnmarshalText(input []byte) error
type Header struct {
	CompactTarget    uint     `json:"compact_target"`
	Dao              Hash     `json:"dao"`
	Epoch            uint64   `json:"epoch"`
	Hash             Hash     `json:"hash"`
	Nonce            *big.Int `json:"nonce"`
	Number           uint64   `json:"number"`
	ParentHash       Hash     `json:"parent_hash"`
	ProposalsHash    Hash     `json:"proposals_hash"`
	Timestamp        uint64   `json:"timestamp"`
	TransactionsRoot Hash     `json:"transactions_root"`
	ExtraHash        Hash     `json:"extra_hash"`
	Version          uint     `json:"version"`
}

type LiveCell

type LiveCell struct {
	CellOutput *CellOutput       `json:"cell_output"`
	CreatedBy  *TransactionPoint `json:"created_by"`
}

type LockHashIndexState

type LockHashIndexState struct {
	BlockHash   Hash   `json:"block_hash"`
	BlockNumber uint64 `json:"block_number"`
	LockHash    Hash   `json:"lock_hash"`
}

type MinerReward added in v0.3.0

type MinerReward struct {
	Primary   *big.Int `json:"primary"`
	Secondary *big.Int `json:"secondary"`
	Committed *big.Int `json:"committed"`
	Proposal  *big.Int `json:"proposal"`
}

type Node

type Node struct {
	Addresses  []*NodeAddress `json:"addresses"`
	IsOutbound bool           `json:"is_outbound"`
	NodeId     string         `json:"node_id"`
	Version    string         `json:"version"`
}

type NodeAddress

type NodeAddress struct {
	Address string `json:"address"`
	Score   uint64 `json:"score"`
}

type OutPoint

type OutPoint struct {
	TxHash Hash `json:"tx_hash"`
	Index  uint `json:"index"`
}

func (*OutPoint) Serialize

func (o *OutPoint) Serialize() ([]byte, error)

Serialize outpoint

type Proof added in v0.43.1

type Proof struct {
	Indices []uint `json:"indices"`
	Lemmas  []Hash `json:"lemmas"`
}

type ProposalWindow added in v0.41.0

type ProposalWindow struct {
	Closest  uint64 `json:"closest"`
	Farthest uint64 `json:"farthest"`
}

type RationalU256 added in v0.41.0

type RationalU256 struct {
	Denom *big.Int `json:"denom"`
	Numer *big.Int `json:"numer"`
}

type RawTxPool added in v0.43.1

type RawTxPool struct {
	Pending  []*Hash `json:"pending"`
	Proposed []*Hash `json:"proposed"`
}

type ReceiverInfo added in v0.3.0

type ReceiverInfo struct {
	Receiver *Script
	Amount   *big.Int
}

type Script

type Script struct {
	CodeHash Hash           `json:"code_hash"`
	HashType ScriptHashType `json:"hash_type"`
	Args     []byte         `json:"args"`
}

func (*Script) Equals

func (script *Script) Equals(obj *Script) bool

func (*Script) Hash

func (script *Script) Hash() (Hash, error)

func (*Script) OccupiedCapacity added in v0.2.0

func (script *Script) OccupiedCapacity() uint64

func (*Script) Serialize

func (script *Script) Serialize() ([]byte, error)

Serialize script

type ScriptHashType

type ScriptHashType string

func DeserializeHashType added in v0.101.1

func DeserializeHashType(hashType string) (ScriptHashType, error)

func (ScriptHashType) Serialize

func (t ScriptHashType) Serialize() ([]byte, error)

type Serializer

type Serializer interface {
	Serialize() ([]byte, error)
}

type SyncState added in v0.43.1

type SyncState struct {
	Ibd                     bool   `json:"ibd"`
	BestKnownBlockNumber    uint64 `json:"best_known_block_number"`
	BestKnownBlockTimestamp uint64 `json:"best_known_block_timestamp"`
	OrphanBlocksCount       uint64 `json:"orphan_blocks_count"`
	InflightBlocksCount     uint64 `json:"inflight_blocks_count"`
	FastTime                uint64 `json:"fast_time"`
	LowTime                 uint64 `json:"low_time"`
	NormalTime              uint64 `json:"normal_time"`
}

type Transaction

type Transaction struct {
	Version     uint          `json:"version"`
	Hash        Hash          `json:"hash"`
	CellDeps    []*CellDep    `json:"cell_deps"`
	HeaderDeps  []Hash        `json:"header_deps"`
	Inputs      []*CellInput  `json:"inputs"`
	Outputs     []*CellOutput `json:"outputs"`
	OutputsData [][]byte      `json:"outputs_data"`
	Witnesses   [][]byte      `json:"witnesses"`
}

func (*Transaction) ComputeHash

func (t *Transaction) ComputeHash() (Hash, error)

func (*Transaction) OutputsCapacity added in v0.3.0

func (t *Transaction) OutputsCapacity() (totalCapacity uint64)

func (*Transaction) Serialize

func (t *Transaction) Serialize() ([]byte, error)

Serialize transaction

func (*Transaction) SizeInBlock added in v0.3.0

func (t *Transaction) SizeInBlock() (uint64, error)

type TransactionPoint

type TransactionPoint struct {
	BlockNumber uint64 `json:"block_number"`
	Index       uint   `json:"index"`
	TxHash      Hash   `json:"tx_hash"`
}

type TransactionProof added in v0.43.1

type TransactionProof struct {
	Proof         *Proof `json:"proof"`
	BlockHash     Hash   `json:"block_hash"`
	WitnessesRoot Hash   `json:"witnesses_root"`
}

type TransactionStatus

type TransactionStatus string

type TransactionWithStatus

type TransactionWithStatus struct {
	Transaction *Transaction `json:"transaction"`
	TxStatus    *TxStatus    `json:"tx_status"`
}

type TxPoolInfo

type TxPoolInfo struct {
	LastTxsUpdatedAt uint64 `json:"last_txs_updated_at"`
	Orphan           uint64 `json:"orphan"`
	Pending          uint64 `json:"pending"`
	Proposed         uint64 `json:"proposed"`
	TotalTxCycles    uint64 `json:"total_tx_cycles"`
	TotalTxSize      uint64 `json:"total_tx_size"`
}

type TxStatus

type TxStatus struct {
	BlockHash *Hash             `json:"block_hash"`
	Status    TransactionStatus `json:"status"`
}

type UncleBlock

type UncleBlock struct {
	Header    *Header  `json:"header"`
	Proposals []string `json:"proposals"`
}

type WitnessArgs

type WitnessArgs struct {
	Lock       []byte `json:"lock"`
	InputType  []byte `json:"input_type"`
	OutputType []byte `json:"output_type"`
}

func DeserializeWitnessArgs added in v1.0.3

func DeserializeWitnessArgs(in []byte) (*WitnessArgs, error)

func (*WitnessArgs) Serialize

func (w *WitnessArgs) Serialize() ([]byte, error)

Jump to

Keyboard shortcuts

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