blockchain

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: Apache-2.0 Imports: 9 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) *Blockchain

func (*Blockchain) GetBlockByHash

func (b *Blockchain) GetBlockByHash(hash *felt.Felt) (block *core.Block, err error)

func (*Blockchain) GetBlockByNumber

func (b *Blockchain) GetBlockByNumber(number uint64) (block *core.Block, err error)

func (*Blockchain) GetBlockHeaderByHash

func (b *Blockchain) GetBlockHeaderByHash(hash *felt.Felt) (header *core.Header, err error)

func (*Blockchain) GetBlockHeaderByNumber

func (b *Blockchain) GetBlockHeaderByNumber(number uint64) (header *core.Header, err error)

func (*Blockchain) GetReceipt

func (b *Blockchain) GetReceipt(hash *felt.Felt) (receipt *core.TransactionReceipt, blockHash *felt.Felt, blockNumber uint64, err error)

GetReceipt gets the transaction receipt for a given transaction hash.

func (*Blockchain) GetStateUpdateByHash

func (b *Blockchain) GetStateUpdateByHash(hash *felt.Felt) (update *core.StateUpdate, err error)

func (*Blockchain) GetStateUpdateByNumber

func (b *Blockchain) GetStateUpdateByNumber(number uint64) (update *core.StateUpdate, err error)

func (*Blockchain) GetTransactionByBlockNumberAndIndex

func (b *Blockchain) GetTransactionByBlockNumberAndIndex(blockNumber, index uint64) (transaction core.Transaction, err error)

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

func (*Blockchain) GetTransactionByHash

func (b *Blockchain) GetTransactionByHash(hash *felt.Felt) (transaction core.Transaction, err error)

GetTransactionByHash gets the transaction for a given hash.

func (*Blockchain) Head

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

func (*Blockchain) HeadsHeader

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

func (*Blockchain) Height

func (b *Blockchain) Height() (height uint64, err 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) SanityCheckNewHeight

func (b *Blockchain) SanityCheckNewHeight(block *core.Block, stateUpdate *core.StateUpdate) error

SanityCheckNewHeight checks integrity of a block and resulting state update

func (*Blockchain) StateCommitment

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

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

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) VerifyBlock

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

VerifyBlock assumes the block has already been sanity-checked.

type ErrIncompatibleBlock

type ErrIncompatibleBlock struct {
	Err error
}

func (ErrIncompatibleBlock) Error

func (e ErrIncompatibleBlock) Error() string

func (ErrIncompatibleBlock) Unwrap

func (e ErrIncompatibleBlock) Unwrap() error

type ErrIncompatibleBlockAndStateUpdate

type ErrIncompatibleBlockAndStateUpdate struct {
	Err error
}

func (ErrIncompatibleBlockAndStateUpdate) Error

func (ErrIncompatibleBlockAndStateUpdate) Unwrap

type Reader

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

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

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

	GetTransactionByHash(hash *felt.Felt) (transaction core.Transaction, err error)
	GetTransactionByBlockNumberAndIndex(blockNumber, index uint64) (transaction core.Transaction, err error)
	GetReceipt(hash *felt.Felt) (receipt *core.TransactionReceipt, blockHash *felt.Felt, blockNumber uint64, err error)
	GetStateUpdateByNumber(number uint64) (update *core.StateUpdate, err error)
	GetStateUpdateByHash(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