blockchain

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Blockchain

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

Blockchain is responsible for keeping track of all things related to the Starknet blockchain

func New

func New(database db.DB, network utils.Network, log utils.SimpleLogger) *Blockchain

func (*Blockchain) BlockByHash added in v0.2.1

func (b *Blockchain) BlockByHash(hash *felt.Felt) (*core.Block, error)

func (*Blockchain) BlockByNumber added in v0.2.1

func (b *Blockchain) BlockByNumber(number uint64) (*core.Block, error)

func (*Blockchain) BlockHeaderByHash added in v0.2.1

func (b *Blockchain) BlockHeaderByHash(hash *felt.Felt) (*core.Header, error)

func (*Blockchain) BlockHeaderByNumber added in v0.2.1

func (b *Blockchain) BlockHeaderByNumber(number uint64) (*core.Header, error)

func (*Blockchain) Head

func (b *Blockchain) Head() (*core.Block, error)

func (*Blockchain) HeadsHeader

func (b *Blockchain) HeadsHeader() (*core.Header, error)

func (*Blockchain) Height

func (b *Blockchain) Height() (uint64, error)

Height returns the latest block height. If blockchain is empty nil is returned.

func (*Blockchain) Network

func (b *Blockchain) Network() utils.Network

func (*Blockchain) Receipt added in v0.2.1

func (b *Blockchain) Receipt(hash *felt.Felt) (*core.TransactionReceipt, *felt.Felt, uint64, error)

Receipt gets the transaction receipt for a given transaction hash.

func (*Blockchain) SanityCheckNewHeight

func (b *Blockchain) SanityCheckNewHeight(block *core.Block, stateUpdate *core.StateUpdate, classes map[felt.Felt]core.Class) error

SanityCheckNewHeight checks integrity of a block and resulting state update

func (*Blockchain) StateCommitment

func (b *Blockchain) StateCommitment() (*felt.Felt, error)

StateCommitment returns the latest block state commitment. If blockchain is empty zero felt is returned.

func (*Blockchain) StateUpdateByHash added in v0.2.1

func (b *Blockchain) StateUpdateByHash(hash *felt.Felt) (*core.StateUpdate, error)

func (*Blockchain) StateUpdateByNumber added in v0.2.1

func (b *Blockchain) StateUpdateByNumber(number uint64) (*core.StateUpdate, error)

func (*Blockchain) Store

func (b *Blockchain) Store(block *core.Block, stateUpdate *core.StateUpdate, declaredClasses map[felt.Felt]core.Class) error

Store takes a block and state update and performs sanity checks before putting in the database.

func (*Blockchain) TransactionByBlockNumberAndIndex added in v0.2.1

func (b *Blockchain) TransactionByBlockNumberAndIndex(blockNumber, index uint64) (core.Transaction, error)

TransactionByBlockNumberAndIndex gets the transaction for a given block number and index.

func (*Blockchain) TransactionByHash added in v0.2.1

func (b *Blockchain) TransactionByHash(hash *felt.Felt) (core.Transaction, error)

TransactionByHash gets the transaction for a given hash.

func (*Blockchain) VerifyBlock

func (b *Blockchain) VerifyBlock(block *core.Block) error

VerifyBlock assumes the block has already been sanity-checked.

type Reader

type Reader interface {
	Height() (height uint64, err error)

	Head() (head *core.Block, err error)
	BlockByNumber(number uint64) (block *core.Block, err error)
	BlockByHash(hash *felt.Felt) (block *core.Block, err error)

	HeadsHeader() (header *core.Header, err error)
	BlockHeaderByNumber(number uint64) (header *core.Header, err error)
	BlockHeaderByHash(hash *felt.Felt) (header *core.Header, err error)

	TransactionByHash(hash *felt.Felt) (transaction core.Transaction, err error)
	TransactionByBlockNumberAndIndex(blockNumber, index uint64) (transaction core.Transaction, err error)
	Receipt(hash *felt.Felt) (receipt *core.TransactionReceipt, blockHash *felt.Felt, blockNumber uint64, err error)
	StateUpdateByNumber(number uint64) (update *core.StateUpdate, err error)
	StateUpdateByHash(hash *felt.Felt) (update *core.StateUpdate, err error)
}

Jump to

Keyboard shortcuts

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