sync

package
v0.14.3 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2025 License: Apache-2.0 Imports: 17 Imported by: 2

Documentation

Index

Constants

View Source
const (
	OpVerify = "verify"
	OpStore  = "store"
	OpFetch  = "fetch"
)

Variables

View Source
var (
	ErrPendingBlockNotFound = errors.New("pending block not found")
)

Functions

This section is empty.

Types

type EventListener added in v0.7.0

type EventListener interface {
	OnSyncStepDone(op string, blockNum uint64, took time.Duration)
	OnReorg(blockNum uint64)
}

type NewHeadSubscription added in v0.13.2

type NewHeadSubscription struct {
	*feed.Subscription[*core.Block]
}

This is a work-around. mockgen chokes when the instantiated generic type is in the interface.

type NoopSynchronizer added in v0.10.0

type NoopSynchronizer struct{}

This is temporary and will be removed once the p2p synchronizer implements this interface.

func (*NoopSynchronizer) HighestBlockHeader added in v0.10.0

func (n *NoopSynchronizer) HighestBlockHeader() *core.Header

func (*NoopSynchronizer) Pending added in v0.13.0

func (n *NoopSynchronizer) Pending() (*Pending, error)

func (*NoopSynchronizer) PendingBlock added in v0.13.0

func (n *NoopSynchronizer) PendingBlock() *core.Block

func (*NoopSynchronizer) PendingState added in v0.13.0

func (n *NoopSynchronizer) PendingState() (core.StateReader, func() error, error)

func (*NoopSynchronizer) StartingBlockNumber added in v0.10.0

func (n *NoopSynchronizer) StartingBlockNumber() (uint64, error)

func (*NoopSynchronizer) SubscribeNewHeads added in v0.10.0

func (n *NoopSynchronizer) SubscribeNewHeads() NewHeadSubscription

func (*NoopSynchronizer) SubscribePending added in v0.13.0

func (n *NoopSynchronizer) SubscribePending() PendingSubscription

func (*NoopSynchronizer) SubscribeReorg added in v0.13.0

func (n *NoopSynchronizer) SubscribeReorg() ReorgSubscription

type Pending added in v0.13.0

type Pending struct {
	Block       *core.Block
	StateUpdate *core.StateUpdate
	NewClasses  map[felt.Felt]core.Class
}

type PendingState added in v0.13.0

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

func NewPendingState added in v0.13.0

func NewPendingState(stateDiff *core.StateDiff, newClasses map[felt.Felt]core.Class, head core.StateReader) *PendingState

func (*PendingState) ChainHeight added in v0.14.3

func (p *PendingState) ChainHeight() (uint64, error)

func (*PendingState) Class added in v0.13.0

func (p *PendingState) Class(classHash *felt.Felt) (*core.DeclaredClass, error)

func (*PendingState) ClassTrie added in v0.13.0

func (p *PendingState) ClassTrie() (*trie.Trie, error)

func (*PendingState) ContractClassHash added in v0.13.0

func (p *PendingState) ContractClassHash(addr *felt.Felt) (*felt.Felt, error)

func (*PendingState) ContractNonce added in v0.13.0

func (p *PendingState) ContractNonce(addr *felt.Felt) (*felt.Felt, error)

func (*PendingState) ContractStorage added in v0.13.0

func (p *PendingState) ContractStorage(addr, key *felt.Felt) (*felt.Felt, error)

func (*PendingState) ContractStorageTrie added in v0.13.0

func (p *PendingState) ContractStorageTrie(addr *felt.Felt) (*trie.Trie, error)

func (*PendingState) ContractTrie added in v0.13.0

func (p *PendingState) ContractTrie() (*trie.Trie, error)

func (*PendingState) StateDiff added in v0.14.3

func (p *PendingState) StateDiff() *core.StateDiff

type PendingStateWriter added in v0.14.3

type PendingStateWriter struct {
	*PendingState
}

func NewPendingStateWriter added in v0.14.3

func NewPendingStateWriter(stateDiff *core.StateDiff, newClasses map[felt.Felt]core.Class, head core.StateReader) PendingStateWriter

func (*PendingStateWriter) IncrementNonce added in v0.14.3

func (p *PendingStateWriter) IncrementNonce(contractAddress *felt.Felt) error

func (*PendingStateWriter) SetClassHash added in v0.14.3

func (p *PendingStateWriter) SetClassHash(contractAddress, classHash *felt.Felt) error

func (*PendingStateWriter) SetCompiledClassHash added in v0.14.3

func (p *PendingStateWriter) SetCompiledClassHash(classHash, compiledClassHash *felt.Felt) error

SetCompiledClassHash writes CairoV1 classes to the pending state Assumption: SetContractClass was called for classHash and succeeded

func (*PendingStateWriter) SetContractClass added in v0.14.3

func (p *PendingStateWriter) SetContractClass(classHash *felt.Felt, class core.Class) error

SetContractClass writes a new CairoV0 class to the PendingState Assumption: SetCompiledClassHash should be called for CairoV1 contracts

func (*PendingStateWriter) SetStateDiff added in v0.14.3

func (p *PendingStateWriter) SetStateDiff(stateDiff *core.StateDiff)

func (*PendingStateWriter) SetStorage added in v0.14.3

func (p *PendingStateWriter) SetStorage(contractAddress, key, value *felt.Felt) error

func (*PendingStateWriter) StateDiffAndClasses added in v0.14.3

func (p *PendingStateWriter) StateDiffAndClasses() (core.StateDiff, map[felt.Felt]core.Class)

StateDiffAndClasses returns the pending state's internal data. The returned objects will continue to be read and modified by the pending state.

type PendingSubscription added in v0.13.0

type PendingSubscription struct {
	*feed.Subscription[*core.Block]
}

type PendingTxSubscription added in v0.13.0

type PendingTxSubscription struct {
	*feed.Subscription[[]core.Transaction]
}

type Reader added in v0.6.2

type Reader interface {
	StartingBlockNumber() (uint64, error)
	HighestBlockHeader() *core.Header
	SubscribeNewHeads() NewHeadSubscription
	SubscribeReorg() ReorgSubscription
	SubscribePending() PendingSubscription

	Pending() (*Pending, error)
	PendingBlock() *core.Block
	PendingState() (core.StateReader, func() error, error)
}

Todo: Since this is also going to be implemented by p2p package we should move this interface to node package

type ReorgBlockRange added in v0.13.0

type ReorgBlockRange struct {
	// StartBlockHash is the hash of the first known block of the orphaned chain
	StartBlockHash *felt.Felt
	// StartBlockNum is the number of the first known block of the orphaned chain
	StartBlockNum uint64
	// The last known block of the orphaned chain
	EndBlockHash *felt.Felt
	// Number of the last known block of the orphaned chain
	EndBlockNum uint64
}

ReorgBlockRange represents data about reorganised blocks, starting and ending block number and hash

type ReorgSubscription added in v0.13.0

type ReorgSubscription struct {
	*feed.Subscription[*ReorgBlockRange]
}

type SelectiveListener added in v0.7.0

type SelectiveListener struct {
	OnSyncStepDoneCb func(op string, blockNum uint64, took time.Duration)
	OnReorgCb        func(blockNum uint64)
}

func (*SelectiveListener) OnReorg added in v0.7.0

func (l *SelectiveListener) OnReorg(blockNum uint64)

func (*SelectiveListener) OnSyncStepDone added in v0.7.0

func (l *SelectiveListener) OnSyncStepDone(op string, blockNum uint64, took time.Duration)

type Synchronizer

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

Synchronizer manages a list of StarknetData to fetch the latest blockchain updates

func New added in v0.2.1

func New(bc *blockchain.Blockchain, starkNetData starknetdata.StarknetData, log utils.SimpleLogger,
	pendingPollInterval time.Duration, readOnlyBlockchain bool, database db.DB,
) *Synchronizer

func (*Synchronizer) HighestBlockHeader added in v0.3.0

func (s *Synchronizer) HighestBlockHeader() *core.Header

func (*Synchronizer) Pending added in v0.13.0

func (s *Synchronizer) Pending() (*Pending, error)

func (*Synchronizer) PendingBlock added in v0.13.0

func (s *Synchronizer) PendingBlock() *core.Block

func (*Synchronizer) PendingState added in v0.13.0

func (s *Synchronizer) PendingState() (core.StateReader, func() error, error)

PendingState returns the state resulting from execution of the pending block

func (*Synchronizer) Run

func (s *Synchronizer) Run(ctx context.Context) error

Run starts the Synchronizer, returns an error if the loop is already running

func (*Synchronizer) StartingBlockNumber added in v0.3.0

func (s *Synchronizer) StartingBlockNumber() (uint64, error)

func (*Synchronizer) StorePending added in v0.13.0

func (s *Synchronizer) StorePending(p *Pending) error

StorePending stores a pending block given that it is for the next height

func (*Synchronizer) SubscribeNewHeads added in v0.7.4

func (s *Synchronizer) SubscribeNewHeads() NewHeadSubscription

func (*Synchronizer) SubscribePending added in v0.13.0

func (s *Synchronizer) SubscribePending() PendingSubscription

func (*Synchronizer) SubscribeReorg added in v0.13.0

func (s *Synchronizer) SubscribeReorg() ReorgSubscription

func (*Synchronizer) WithListener added in v0.7.0

func (s *Synchronizer) WithListener(listener EventListener) *Synchronizer

WithListener registers an EventListener

func (*Synchronizer) WithPlugin added in v0.12.3

func (s *Synchronizer) WithPlugin(plugin junoplugin.JunoPlugin) *Synchronizer

WithPlugin registers an plugin

Jump to

Keyboard shortcuts

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