types

package
v0.0.0-...-e920dd0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BloomByteLength represents the number of bytes used in a header log bloom.
	BloomByteLength = 256

	// BloomBitLength represents the number of bits used in a header log bloom.
	BloomBitLength = 8 * BloomByteLength
)

Variables

View Source
var Bloom9 = bloom9
View Source
var ParameterTypeMap = map[string]ContractParameterType{
	"Signature": Signature,
	"Boolean":   Boolean,
	"Integer":   Integer,
	"Hash160":   Hash160,
	"Hash256":   Hash256,
	"ByteArray": ByteArray,
	"PublicKey": PublicKey,
	"String":    String,
	"Object":    Object,
	"Hash168":   Hash168,
	"Array":     Array,
	"Void":      Void,
}

Functions

func BloomLookup

func BloomLookup(bin Bloom, topic bytesBacked) bool

func ContractParameterTypeToByte

func ContractParameterTypeToByte(c []ContractParameterType) []byte

func IsMultiSigContract

func IsMultiSigContract(script []byte) bool

func IsSignatureCotract

func IsSignatureCotract(script []byte) bool

func LogsBloom

func LogsBloom(logs []*Nep5Log) *big.Int

Types

type Bloom

type Bloom [BloomByteLength]byte

Bloom represents a 2048 bit bloom filter.

func BytesToBloom

func BytesToBloom(b []byte) Bloom

BytesToBloom converts a byte slice to a bloom filter. It panics if b is not of suitable size.

func CreateBloom

func CreateBloom(receipts Receipts) Bloom

func (*Bloom) Add

func (b *Bloom) Add(d *big.Int)

Add adds d to the filter. Future calls of Test(d) will return true.

func (Bloom) Big

func (b Bloom) Big() *big.Int

Big converts b to a big integer.

func (Bloom) Bytes

func (b Bloom) Bytes() []byte

func (*Bloom) SetBytes

func (b *Bloom) SetBytes(d []byte)

SetBytes sets the content of b to the given bytes. It panics if d is not of suitable size.

func (Bloom) Test

func (b Bloom) Test(test *big.Int) bool

func (Bloom) TestBytes

func (b Bloom) TestBytes(test []byte) bool

type Contract

type Contract struct {

	//the contract program code,which will be run on VM or specific envrionment
	Code []byte

	//the Contract Parameter type list
	// describe the number of contract program parameters and the parameter type
	Parameters []ContractParameterType

	//The program hash as contract address
	ProgramHash common.Uint168

	//owner's pubkey hash indicate the owner of contract
	OwnerPubkeyHash common.Uint168
}

Contract include the program codes with parameters which can be executed on specific evnrioment

func (*Contract) Deserialize

func (c *Contract) Deserialize(r io.Reader) error

func (*Contract) Serialize

func (c *Contract) Serialize(w io.Writer) error

func (*Contract) ToArray

func (c *Contract) ToArray() []byte

type ContractParameterType

type ContractParameterType byte

parameter defined type.

const (
	Signature ContractParameterType = iota
	Boolean
	Integer
	Hash160
	Hash256
	ByteArray
	PublicKey
	String
	Object
	Hash168
	Array = 0x10
	Void  = 0xff
)

func ByteToContractParameterType

func ByteToContractParameterType(b []byte) []ContractParameterType

type FunctionCode

type FunctionCode struct {
	// Contract Code
	Code []byte

	// Contract parameter type list
	ParameterTypes []ContractParameterType

	// Contract return type list
	ReturnType ContractParameterType
	// contains filtered or unexported fields
}

func (*FunctionCode) CodeHash

func (fc *FunctionCode) CodeHash() common.Uint168

Get the hash of the smart contract

func (*FunctionCode) Deserialize

func (fc *FunctionCode) Deserialize(r io.Reader) error

method of SerializableData

func (*FunctionCode) GetCode

func (fc *FunctionCode) GetCode() []byte

Get code

func (*FunctionCode) GetParameterTypes

func (fc *FunctionCode) GetParameterTypes() []ContractParameterType

Get the list of parameter value

func (*FunctionCode) GetReturnType

func (fc *FunctionCode) GetReturnType() ContractParameterType

Get the list of return value

func (*FunctionCode) Serialize

func (fc *FunctionCode) Serialize(w io.Writer) error

method of SerializableData

type Header struct {
	*types.Header

	ReceiptHash common.Uint256
	Bloom       []byte
}

func NewHeader

func NewHeader() *Header

func (*Header) Deserialize

func (header *Header) Deserialize(r io.Reader) error

func (*Header) GetAuxPow

func (header *Header) GetAuxPow() *auxpow.SideAuxPow

func (*Header) GetBits

func (header *Header) GetBits() uint32

func (*Header) GetHeight

func (header *Header) GetHeight() uint32

func (*Header) GetMerkleRoot

func (header *Header) GetMerkleRoot() common.Uint256

func (*Header) GetNonce

func (header *Header) GetNonce() uint32

func (*Header) GetPrevious

func (header *Header) GetPrevious() common.Uint256

func (*Header) GetTimeStamp

func (header *Header) GetTimeStamp() uint32

func (*Header) GetVersion

func (header *Header) GetVersion() uint32

func (*Header) Hash

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

func (*Header) Serialize

func (header *Header) Serialize(w io.Writer) error

func (*Header) SetAuxPow

func (header *Header) SetAuxPow(sideAuxPow *auxpow.SideAuxPow)

func (*Header) SetBits

func (header *Header) SetBits(bits uint32)

func (*Header) SetHeight

func (header *Header) SetHeight(height uint32)

func (*Header) SetMerkleRoot

func (header *Header) SetMerkleRoot(root common.Uint256)

func (*Header) SetNonce

func (header *Header) SetNonce(nonce uint32)

func (*Header) SetPrevious

func (header *Header) SetPrevious(previous common.Uint256)

func (*Header) SetTimeStamp

func (header *Header) SetTimeStamp(timestamp uint32)

func (*Header) SetVersion

func (header *Header) SetVersion(version uint32)

type Nep5Log

type Nep5Log struct {
	// Consensus fields:
	// address of the contract that generated the event
	Address string

	// nep5 address on transfer about from and to
	From common.Uint160

	To common.Uint160

	Data big.Int

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

Nep5Log represents a contract log event. These events are generated by the nep5 transfer event by the node.

func (*Nep5Log) Deserialize

func (l *Nep5Log) Deserialize(r io.Reader, version byte) error

func (*Nep5Log) Serialize

func (l *Nep5Log) Serialize(w io.Writer, version byte) error

func (*Nep5Log) String

func (l *Nep5Log) String() string

type PayloadDeploy

type PayloadDeploy struct {
	Code        *FunctionCode
	Name        string
	CodeVersion string
	Author      string
	Email       string
	Description string
	ProgramHash common.Uint168
	Gas         common.Fixed64
}

func (*PayloadDeploy) Data

func (dc *PayloadDeploy) Data(version byte) []byte

func (*PayloadDeploy) Deserialize

func (dc *PayloadDeploy) Deserialize(r io.Reader, version byte) error

func (*PayloadDeploy) Serialize

func (dc *PayloadDeploy) Serialize(w io.Writer, version byte) error

type PayloadInvoke

type PayloadInvoke struct {
	CodeHash    common.Uint168
	Code        []byte
	ProgramHash common.Uint168
	Gas         common.Fixed64
}

func (*PayloadInvoke) Data

func (ic *PayloadInvoke) Data(version byte) []byte

func (*PayloadInvoke) Deserialize

func (ic *PayloadInvoke) Deserialize(r io.Reader, version byte) error

func (*PayloadInvoke) Serialize

func (ic *PayloadInvoke) Serialize(w io.Writer, version byte) error

type Receipt

type Receipt struct {
	// Consensus fields: These fields are defined by the Yellow Paper
	Status bool       `json:"status"`
	Logs   []*Nep5Log `json:"logs"              gencodec:"required"`

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

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

Receipt represents the results of a transaction.

func NewReceipt

func NewReceipt(contractAddr common.Uint168, tx *types.Transaction, block *types.Block) (*Receipt, error)

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

func (*Receipt) Deserialize

func (receipt *Receipt) Deserialize(r io.Reader, version byte) error

func (*Receipt) GetTxIndex

func (r *Receipt) GetTxIndex(txHash common.Uint256, block *types.Block) (uint32, error)

func (*Receipt) Serialize

func (r *Receipt) Serialize(w io.Writer, version byte) error

type Receipts

type Receipts []*Receipt

func (Receipts) Hash

func (r Receipts) Hash() common.Uint256

Jump to

Keyboard shortcuts

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