blockchaininfo

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockUpdates    = "block_topic"
	ContractUpdates = "contract_topic"
	ConstantKeys    = "constant_keys"
)
View Source
const (
	StartPaging = iota
	EndPaging
	NoPaging
)
View Source
const (
	RootHashSize = 32

	HistoryJournalLengthMax = 100
)
View Source
const L2RequestsTopic = "l2_requests_topic"
View Source
const NatsConnectionsTimeoutDefault = 10 * server.AUTH_TIMEOUT
View Source
const RequestRestartSubTopic = "restart"
View Source
const StoreBlocksLimit = 200
View Source
const UpdatesBufferedChannelSize = 256

Variables

View Source
var ErrNotInCache = errors.New("the target height is not in cache")

Functions

func BlockUpdatesInfoFromProto

func BlockUpdatesInfoFromProto(blockInfoProto *g.BlockInfo) (proto.BlockUpdatesInfo, error)

func BlockUpdatesInfoToProto

func BlockUpdatesInfoToProto(blockInfo proto.BlockUpdatesInfo, scheme proto.Scheme) (*g.BlockInfo, error)

func CompareBUpdatesInfo

func CompareBUpdatesInfo(current, previous proto.BUpdatesInfo,
	scheme proto.Scheme) (bool, proto.BUpdatesInfo, error)

func ConcatenateContractTopics

func ConcatenateContractTopics(contractAddress string) string

func DeserializeConstantKeys

func DeserializeConstantKeys(data []byte) ([]string, error)

func HandleRollback

func HandleRollback(ctx context.Context, be *BUpdatesExtensionState, updates proto.BUpdatesInfo,
	updatesPublisher UpdatesPublisherInterface,
	nc *nats.Conn, scheme proto.Scheme) proto.BUpdatesInfo

func L2ContractDataEntriesFromProto

func L2ContractDataEntriesFromProto(
	protoDataEntries *g.L2ContractDataEntries,
	scheme proto.Scheme,
) (proto.L2ContractDataEntries, error)

func L2ContractDataEntriesToProto

func L2ContractDataEntriesToProto(contractData proto.L2ContractDataEntries) *g.L2ContractDataEntries

func PublishBlockUpdates

func PublishBlockUpdates(updates proto.BUpdatesInfo, nc *nats.Conn, scheme proto.Scheme) error

func PublishContractUpdates

func PublishContractUpdates(ctx context.Context,
	contractUpdates proto.L2ContractDataEntries, nc *nats.Conn,
	l2ContractAddress string) error

func SerializeConstantKeys

func SerializeConstantKeys(constantKeys []string) ([]byte, error)

Types

type BUpdatesExtensionState

type BUpdatesExtensionState struct {
	CurrentState  *proto.BUpdatesInfo
	PreviousState *proto.BUpdatesInfo // this information is what was just published
	Limit         uint64
	Scheme        proto.Scheme

	L2ContractAddress string
	HistoryJournal    *HistoryJournal
	St                state.State
	// contains filtered or unexported fields
}

func NewBUpdatesExtensionState

func NewBUpdatesExtensionState(limit uint64, scheme proto.Scheme, l2ContractAddress string,
	st state.State) (*BUpdatesExtensionState, error)

func (*BUpdatesExtensionState) AddEntriesToHistoryJournalAndCache

func (bu *BUpdatesExtensionState) AddEntriesToHistoryJournalAndCache(updates proto.BUpdatesInfo)

func (*BUpdatesExtensionState) BuildPatch

func (bu *BUpdatesExtensionState) BuildPatch(keysForPatch []string, targetHeight uint64) (proto.DataEntries,
	proto.BlockUpdatesInfo, error)

func (*BUpdatesExtensionState) CleanRecordsAfterRollback

func (bu *BUpdatesExtensionState) CleanRecordsAfterRollback(latestHeightFromHistory uint64,
	heightAfterRollback uint64) error

func (*BUpdatesExtensionState) GeneratePatch

func (bu *BUpdatesExtensionState) GeneratePatch(latestUpdates proto.BUpdatesInfo) (proto.BUpdatesInfo, error)

func (*BUpdatesExtensionState) HasStateChanged

func (bu *BUpdatesExtensionState) HasStateChanged() (bool, proto.BUpdatesInfo, error)

func (*BUpdatesExtensionState) IsKeyConstant

func (bu *BUpdatesExtensionState) IsKeyConstant(keyDataEntry string) bool

func (*BUpdatesExtensionState) RollbackHappened

func (bu *BUpdatesExtensionState) RollbackHappened(updates proto.BUpdatesInfo, previousState proto.BUpdatesInfo) bool

func (*BUpdatesExtensionState) SetPreviousState

func (bu *BUpdatesExtensionState) SetPreviousState(updates proto.BUpdatesInfo)

func (*BUpdatesExtensionState) StatesEqual

func (bu *BUpdatesExtensionState) StatesEqual(scheme proto.Scheme) (bool, proto.BUpdatesInfo, error)

type BlockMeta

type BlockMeta struct {
	BlockHeight          int64  `json:"blockHeight"`
	BlockEpoch           int64  `json:"blockEpoch"`
	BlockParent          []byte `json:"blockParent"`
	ChainID              int64  `json:"chainId"`
	E2CTransfersRootHash []byte `json:"e2cTransfersRootHash"`
	LastC2ETransferIndex int64  `json:"lastC2ETransferIndex"`
}

func (*BlockMeta) UnmarshalBinary

func (bm *BlockMeta) UnmarshalBinary(value []byte) error

type BlockchainUpdatesExtension

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

func NewBlockchainUpdatesExtension

func NewBlockchainUpdatesExtension(
	l2ContractAddress proto.WavesAddress,
	blockchainExtensionState *BUpdatesExtensionState,
	makeExtensionReadyFunc func(),
	obsolescencePeriod time.Duration,
	ntpTime types.Time,
) *BlockchainUpdatesExtension

func (*BlockchainUpdatesExtension) ClearPreviousState

func (e *BlockchainUpdatesExtension) ClearPreviousState()

func (*BlockchainUpdatesExtension) L2ContractAddress

func (e *BlockchainUpdatesExtension) L2ContractAddress() proto.WavesAddress

func (*BlockchainUpdatesExtension) MarkExtensionReady

func (e *BlockchainUpdatesExtension) MarkExtensionReady()

func (*BlockchainUpdatesExtension) RunBlockchainUpdatesPublisher

func (e *BlockchainUpdatesExtension) RunBlockchainUpdatesPublisher(ctx context.Context,
	scheme proto.Scheme,
	updatesChannel <-chan proto.BUpdatesInfo) error

type HistoryEntry

type HistoryEntry struct {
	Height      uint64
	BlockID     proto.BlockID
	VRF         proto.B58Bytes
	BlockHeader proto.BlockHeader

	Entries proto.DataEntries
}

type HistoryJournal

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

func NewHistoryJournal

func NewHistoryJournal() *HistoryJournal

func (*HistoryJournal) CleanAfterRollback

func (hj *HistoryJournal) CleanAfterRollback(latestHeightFromHistory uint64, heightAfterRollback uint64) error

CleanAfterRollback TODO write tests.

func (*HistoryJournal) FetchKeysUntilBlockID

func (hj *HistoryJournal) FetchKeysUntilBlockID(blockID proto.BlockID) ([]string, bool)

FetchKeysUntilBlockID TODO write tests. FetchKeysUntilBlockID goes from top to bottom and fetches all keys. If the blockID is found, it returns the keys up to and including that element and true. If the blockID is not found - nil and false.

func (*HistoryJournal) Pop

func (hj *HistoryJournal) Pop() (HistoryEntry, error)

func (*HistoryJournal) Push

func (hj *HistoryJournal) Push(v HistoryEntry)

func (*HistoryJournal) SearchByBlockID

func (hj *HistoryJournal) SearchByBlockID(blockID proto.BlockID) (HistoryEntry, bool)

SearchByBlockID TODO write tests.

func (*HistoryJournal) SetStateCache

func (hj *HistoryJournal) SetStateCache(stateCache *StateCache)

func (*HistoryJournal) TopHeight

func (hj *HistoryJournal) TopHeight() (uint64, error)

SearchByBlockID TODO write tests.

type StateCache

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

func NewStateCache

func NewStateCache() *StateCache

func (*StateCache) AddCacheRecord

func (sc *StateCache) AddCacheRecord(height uint64, dataEntries []proto.DataEntry, blockInfo proto.BlockUpdatesInfo)

func (*StateCache) RemoveCacheRecord

func (sc *StateCache) RemoveCacheRecord(targetHeight uint64)

func (*StateCache) SearchBlockInfo

func (sc *StateCache) SearchBlockInfo(height uint64) (proto.BlockUpdatesInfo, error)

func (*StateCache) SearchValue

func (sc *StateCache) SearchValue(key string, height uint64) (proto.DataEntry, bool)

type StateCacheRecord

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

func NewStateCacheRecord

func NewStateCacheRecord(dataEntries []proto.DataEntry, blockInfo proto.BlockUpdatesInfo) StateCacheRecord

type UpdatesPublisher

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

func (*UpdatesPublisher) L2ContractAddress

func (p *UpdatesPublisher) L2ContractAddress() string

func (*UpdatesPublisher) PublishUpdates

func (p *UpdatesPublisher) PublishUpdates(ctx context.Context,
	updates proto.BUpdatesInfo,
	nc *nats.Conn, scheme proto.Scheme, l2ContractAddress string) error

type UpdatesPublisherInterface

type UpdatesPublisherInterface interface {
	PublishUpdates(ctx context.Context, updates proto.BUpdatesInfo,
		nc *nats.Conn, scheme proto.Scheme, l2ContractAddress string) error
	L2ContractAddress() string
}

Jump to

Keyboard shortcuts

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