types

package
v2.13.0-beta0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hashable

type Hashable interface {
	fmt.Stringer
	comparable

	Bytes() []byte
}

A chain-agnostic generic interface to represent the following native types on various chains: PublicKey, Address, Account, BlockHash, TxHash

type Head[BLOCK_HASH Hashable] interface {
	// BlockNumber is the head's block number
	BlockNumber() int64

	// Timestamp the time of mining of the block
	GetTimestamp() time.Time

	// ChainLength returns the length of the chain followed by recursively looking up parents
	ChainLength() uint32

	// EarliestHeadInChain traverses through parents until it finds the earliest one
	EarliestHeadInChain() Head[BLOCK_HASH]

	// Parent is the head's parent block
	GetParent() Head[BLOCK_HASH]

	// Hash is the head's block hash
	BlockHash() BLOCK_HASH
	GetParentHash() BLOCK_HASH

	// HashAtHeight returns the hash of the block at the given height, if it is in the chain.
	// If not in chain, returns the zero hash
	HashAtHeight(blockNum int64) BLOCK_HASH

	// Returns the total difficulty of the block. For chains who do not have a concept of block
	// difficulty, return 0.
	BlockDifficulty() *big.Int
	// IsValid returns true if the head is valid.
	IsValid() bool

	// Returns the latest finalized based on finality tag or depth
	LatestFinalizedHead() Head[BLOCK_HASH]
}

Head provides access to a chain's head, as needed by the TxManager. This is a generic interface which ALL chains will implement.

type ID added in v2.3.0

type ID fmt.Stringer

ID represents the base type, for any chain's ID. It should be convertible to a string, that can uniquely identify this chain

func NewIDFromInt added in v2.8.0

func NewIDFromInt(id int64) ID

func RandomID added in v2.8.0

func RandomID() ID

type Receipt added in v2.8.0

type Receipt[TX_HASH Hashable, BLOCK_HASH Hashable] interface {
	GetStatus() uint64
	GetTxHash() TX_HASH
	GetBlockNumber() *big.Int
	IsZero() bool
	IsUnmined() bool
	GetFeeUsed() uint64
	GetTransactionIndex() uint
	GetBlockHash() BLOCK_HASH
}

type Sequence added in v2.3.0

type Sequence interface {
	fmt.Stringer
	Int64() int64 // needed for numeric sequence confirmation - to be removed with confirmation logic generalization: https://smartcontract-it.atlassian.net/browse/BCI-860
}

Sequence represents the base type, for any chain's sequence object. It should be convertible to a string

type Subscription added in v2.3.0

type Subscription interface {
	// Unsubscribe cancels the sending of events to the data channel
	// and closes the error channel.
	Unsubscribe()
	// Err returns the subscription error channel. The error channel receives
	// a value if there is an issue with the subscription (e.g. the network connection
	// delivering the events has been closed). Only one value will ever be sent.
	// The error channel is closed by Unsubscribe.
	Err() <-chan error
}

Subscription represents an event subscription where events are delivered on a data channel. This is a generic interface for Subscription to represent used by clients.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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