types

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2024 License: LGPL-3.0 Imports: 17 Imported by: 308

Documentation

Overview

* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library. * * The ontology is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The ontology is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with The ontology. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

View Source
const (
	// ReceiptStatusFailed is the status code of a transaction if execution failed.
	ReceiptStatusFailed = uint64(0)

	// ReceiptStatusSuccessful is the status code of a transaction if execution succeeded.
	ReceiptStatusSuccessful = uint64(1)
)
View Source
const (
	CURR_CROSS_STATES_VERSION = 0
)
View Source
const MAX_TX_SIZE = 1024 * 1024 // The max size of a transaction to prevent DOS attacks

Variables

View Source
var CheckChainID = false

this flag is used for check EIP155 transaction chainID will be set to 'true' on ontology startup ,for sdk dependency will always be 'false'

Functions

func AddressFromBookkeepers

func AddressFromBookkeepers(bookkeepers []keypair.PublicKey) (common.Address, error)

func AddressFromMultiPubKeys

func AddressFromMultiPubKeys(pubkeys []keypair.PublicKey, m int) (common.Address, error)

func AddressFromPubKey

func AddressFromPubKey(pubkey keypair.PublicKey) common.Address

func IsValidAttributeType

func IsValidAttributeType(usage TransactionAttributeUsage) bool

Types

type Block

type Block struct {
	Header       *Header
	Transactions []*Transaction
}

func BlockFromRawBytes added in v1.0.3

func BlockFromRawBytes(raw []byte) (*Block, error)

if no error, ownership of param raw is transfered to Transaction

func (*Block) Deserialization added in v1.0.3

func (self *Block) Deserialization(source *common.ZeroCopySource) error

func (*Block) Hash

func (b *Block) Hash() common.Uint256

func (*Block) RebuildMerkleRoot

func (b *Block) RebuildMerkleRoot()

func (*Block) Serialization added in v1.0.3

func (b *Block) Serialization(sink *common.ZeroCopySink)

func (*Block) ToArray

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

type CrossChainMsg added in v1.9.0

type CrossChainMsg struct {
	Version    byte
	Height     uint32
	StatesRoot common.Uint256

	SigData [][]byte
	// contains filtered or unexported fields
}

func (*CrossChainMsg) Deserialization added in v1.9.0

func (this *CrossChainMsg) Deserialization(source *common.ZeroCopySource) error

func (*CrossChainMsg) Hash added in v1.9.0

func (this *CrossChainMsg) Hash() common.Uint256

func (*CrossChainMsg) Serialization added in v1.9.0

func (this *CrossChainMsg) Serialization(sink *common.ZeroCopySink)

func (*CrossChainMsg) SetHash added in v1.9.0

func (this *CrossChainMsg) SetHash(hash common.Uint256)
type Header struct {
	Version          uint32
	PrevBlockHash    common.Uint256
	TransactionsRoot common.Uint256
	BlockRoot        common.Uint256
	Timestamp        uint32
	Height           uint32
	ConsensusData    uint64
	ConsensusPayload []byte
	NextBookkeeper   common.Address

	//Program *program.Program
	Bookkeepers []keypair.PublicKey
	SigData     [][]byte
	// contains filtered or unexported fields
}

func HeaderFromRawBytes added in v1.0.3

func HeaderFromRawBytes(raw []byte) (*Header, error)

func (*Header) Deserialization added in v1.0.3

func (bd *Header) Deserialization(source *common.ZeroCopySource) error

func (*Header) GetRawHeader added in v1.6.2

func (hd *Header) GetRawHeader() *RawHeader

func (*Header) Hash

func (bd *Header) Hash() common.Uint256

func (*Header) Serialization added in v1.0.3

func (bd *Header) Serialization(sink *common.ZeroCopySink)

func (*Header) ToArray

func (bd *Header) ToArray() []byte

type Log added in v1.14.1

type Log struct {
	// Consensus fields:
	// address of the contract that generated the event
	Address common.Address `json:"address" gencodec:"required"`
	// list of topics provided by the contract.
	Topics []common.Hash `json:"topics" gencodec:"required"`
	// supplied by the contract, usually ABI-encoded
	Data []byte `json:"data" gencodec:"required"`

	// Derived fields. These fields are filled in by the node
	// but not secured by consensus.
	// block in which the transaction was included
	BlockNumber uint64 `json:"blockNumber"`
	// hash of the transaction
	TxHash common.Hash `json:"transactionHash" gencodec:"required"`
	// index of the transaction in the block
	TxIndex uint `json:"transactionIndex"`
	// hash of the block in which the transaction was included
	BlockHash common.Hash `json:"blockHash"`
	// index of the log in the block
	Index uint `json:"logIndex"`
}

Log represents a contract log event. These events are generated by the LOG opcode and stored/indexed by the node.

func (*Log) ToStorageLog added in v1.14.1

func (l *Log) ToStorageLog() *StorageLog

type MutableTransaction added in v1.0.3

type MutableTransaction struct {
	Version  byte
	TxType   TransactionType
	Nonce    uint32
	GasPrice uint64
	GasLimit uint64
	Payer    common.Address
	Payload  Payload

	Sigs []Sig
	// contains filtered or unexported fields
}

func (*MutableTransaction) GetSignatureAddresses added in v1.0.3

func (self *MutableTransaction) GetSignatureAddresses() []common.Address

func (*MutableTransaction) Hash added in v1.0.3

func (self *MutableTransaction) Hash() common.Uint256

func (*MutableTransaction) IntoImmutable added in v1.0.3

func (self *MutableTransaction) IntoImmutable() (*Transaction, error)

output has no reference to self

type Payload

type Payload interface {
	//Serialize payload data
	Serialization(sink *common.ZeroCopySink)
	Deserialization(source *common.ZeroCopySource) error
}

Payload define the func for loading the payload data base on payload type which have different structure

type RawHeader added in v1.6.2

type RawHeader struct {
	Height  uint32
	Payload []byte
}

func (*RawHeader) Deserialization added in v1.6.2

func (self *RawHeader) Deserialization(source *common.ZeroCopySource) error

note: can only be called when source is trusted, like data from local ledger store

func (*RawHeader) Serialization added in v1.6.2

func (self *RawHeader) Serialization(sink *common.ZeroCopySink)

type RawSig added in v1.0.3

type RawSig struct {
	Invoke []byte
	Verify []byte
}

func (*RawSig) Deserialization added in v1.0.3

func (self *RawSig) Deserialization(source *common.ZeroCopySource) error

func (*RawSig) GetSig added in v1.0.3

func (self *RawSig) GetSig() (Sig, error)

func (*RawSig) Serialization added in v1.0.3

func (self *RawSig) Serialization(sink *common.ZeroCopySink) error

type Receipt added in v1.14.1

type Receipt struct {
	Status            uint64        `json:"status"`
	CumulativeGasUsed uint64        `json:"cumulativeGasUsed"`
	Logs              []*StorageLog `json:"logs"`

	// Implementation fields: These fields are added by geth when processing a transaction.
	// They are stored in the chain database.
	TxHash          common.Hash    `json:"transactionHash" gencodec:"required"`
	ContractAddress common.Address `json:"contractAddress"`
	GasUsed         uint64         `json:"gasUsed" gencodec:"required"`
	GasPrice        uint64         //

	// Inclusion information: These fields provide information about the inclusion of the
	// transaction corresponding to this receipt.
	BlockHash   common.Hash `json:"blockHash,omitempty"`
	BlockNumber *big.Int    `json:"blockNumber,omitempty"`
	TxIndex     uint32      `json:"transactionIndex"`
}

Receipt represents the results of a transaction.

func NewReceipt added in v1.14.1

func NewReceipt(failed bool, cumulativeGasUsed uint64) *Receipt

NewReceipt creates a barebone transaction receipt, copying the init fields.

type Sig

type Sig struct {
	SigData [][]byte
	PubKeys []keypair.PublicKey
	M       uint16
}

func (*Sig) GetRawSig added in v1.0.3

func (self *Sig) GetRawSig() (*RawSig, error)

func (*Sig) Serialization added in v1.0.3

func (self *Sig) Serialization(sink *common.ZeroCopySink) error

type SmartCodeEvent

type SmartCodeEvent struct {
	TxHash common.Uint256
	Action string
	Result interface{}
	Error  int64
}

type StorageLog added in v1.14.1

type StorageLog struct {
	Address common.Address
	Topics  []common.Hash
	Data    []byte
}

func (*StorageLog) Deserialization added in v1.14.1

func (self *StorageLog) Deserialization(source *common2.ZeroCopySource) error

func (*StorageLog) Serialization added in v1.14.1

func (self *StorageLog) Serialization(sink *common2.ZeroCopySink)

type Transaction

type Transaction struct {
	Version  byte
	TxType   TransactionType
	Nonce    uint32
	GasPrice uint64
	GasLimit uint64
	Payer    common.Address
	Payload  Payload

	Sigs []RawSig

	Raw []byte // raw transaction data

	SignedAddr []common.Address // this is assigned when passed signature verification
	// contains filtered or unexported fields
}

func TransactionFromEIP155 added in v1.14.1

func TransactionFromEIP155(eiptx *types.Transaction) (*Transaction, error)

func TransactionFromRawBytes added in v1.0.3

func TransactionFromRawBytes(raw []byte) (*Transaction, error)

if no error, ownership of param raw is transfered to Transaction

func (*Transaction) Cost added in v1.14.1

func (tx *Transaction) Cost() *big.Int

func (*Transaction) Deserialization added in v1.0.3

func (tx *Transaction) Deserialization(source *common.ZeroCopySource) error

Transaction has internal reference of param `source`

func (*Transaction) GetEIP155Tx added in v1.14.1

func (tx *Transaction) GetEIP155Tx() (*types.Transaction, error)

func (*Transaction) GetSignatureAddresses

func (self *Transaction) GetSignatureAddresses() []common.Address

func (*Transaction) Hash

func (tx *Transaction) Hash() common.Uint256

func (*Transaction) IntoMutable added in v1.0.3

func (tx *Transaction) IntoMutable() (*MutableTransaction, error)

note: ownership transfered to output

func (*Transaction) IsEipTx added in v1.14.1

func (tx *Transaction) IsEipTx() bool

func (*Transaction) Serialization added in v1.0.3

func (tx *Transaction) Serialization(sink *common.ZeroCopySink)

func (*Transaction) SigHashForChain added in v1.13.0

func (tx *Transaction) SigHashForChain(id uint32) common.Uint256

calculate a hash for another chain to sign. and take the chain id of ontology as 0.

func (*Transaction) ToArray

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

func (*Transaction) Value added in v1.14.1

func (tx *Transaction) Value() *big.Int

type TransactionAttributeUsage

type TransactionAttributeUsage byte
const (
	Nonce          TransactionAttributeUsage = 0x00
	Script         TransactionAttributeUsage = 0x20
	DescriptionUrl TransactionAttributeUsage = 0x81
	Description    TransactionAttributeUsage = 0x90
)

type TransactionType

type TransactionType byte
const (
	Deploy     TransactionType = 0xd0
	InvokeNeo  TransactionType = 0xd1
	InvokeWasm TransactionType = 0xd2 //add for wasm invoke
	EIP155     TransactionType = 0xd3 //for EIP155 transaction
)

type TxAttribute

type TxAttribute struct {
	Usage TransactionAttributeUsage
	Data  []byte
	Size  uint32
}

func NewTxAttribute

func NewTxAttribute(u TransactionAttributeUsage, d []byte) TxAttribute

func (*TxAttribute) Deserialization added in v1.8.1

func (tx *TxAttribute) Deserialization(source *common.ZeroCopySource) error

func (*TxAttribute) GetSize

func (u *TxAttribute) GetSize() uint32

func (*TxAttribute) Serialization added in v1.8.1

func (tx *TxAttribute) Serialization(sink *common.ZeroCopySink) error

func (*TxAttribute) ToArray

func (tx *TxAttribute) ToArray() []byte

Jump to

Keyboard shortcuts

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