block

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigCacheCap = 10
)
View Source
const (
	ResultNotFinalizedError = errors.CodeBlock + iota
)
View Source
const V2String = "2.0"

Variables

View Source
var (
	ErrResultNotFinalized = errors.NewBase(ResultNotFinalizedError, "ResultNotFinalized")
)

Functions

func FormatFromBlock added in v1.3.0

func FormatFromBlock(blk module.Block) (*V2HeaderFormat, *V2BodyFormat, error)

func GetBTPDigestFromResult added in v1.3.0

func GetBTPDigestFromResult(
	dbase db.Database,
	c codec.Codec,
	result []byte,
) (module.BTPDigest, error)

func GetBlockHeaderHashByHeight added in v1.1.1

func GetBlockHeaderHashByHeight(
	dbase db.Database,
	c codec.Codec,
	height int64,
) ([]byte, error)

func GetBlockResultByHeight added in v1.3.0

func GetBlockResultByHeight(
	dbase db.Database,
	c codec.Codec,
	height int64,
) ([]byte, error)

func GetBlockVersion added in v1.1.1

func GetBlockVersion(
	dbase db.Database,
	c codec.Codec,
	height int64,
) (int, error)

func GetCommitVoteListBytesForHeight added in v1.3.0

func GetCommitVoteListBytesForHeight(
	dbase db.Database,
	c codec.Codec,
	height int64,
) ([]byte, error)

func GetLastHeight added in v0.9.4

func GetLastHeight(dbase db.Database) (int64, error)

func GetLastHeightOf

func GetLastHeightOf(dbase db.Database) int64

func GetLastHeightWithCodec added in v1.1.1

func GetLastHeightWithCodec(dbase db.Database, c codec.Codec) (int64, error)

func GetNextValidatorsByHeight added in v1.3.0

func GetNextValidatorsByHeight(
	dbase db.Database,
	c codec.Codec,
	height int64,
) (module.ValidatorList, error)

func NewBlockDataFactory added in v1.2.11

func NewBlockDataFactory(
	c module.Chain,
	handlers []base.BlockHandler,
) (module.BlockDataFactory, error)

func NewBlockReaderFromFormat added in v1.3.0

func NewBlockReaderFromFormat(hf *V2HeaderFormat, bf *V2BodyFormat) io.Reader

func NewBlockV2Handler added in v0.9.6

func NewBlockV2Handler(chain base.Chain) base.BlockHandler

func NewManager

func NewManager(
	chain module.Chain,
	timestamper module.Timestamper,
	handlers []base.BlockHandler,
) (module.BlockManager, error)

NewManager creates BlockManager.

func PeekVersion added in v0.9.8

func PeekVersion(r io.Reader) (int, io.Reader, error)

func ReadVersion added in v0.9.10

func ReadVersion(r io.Reader) (int, error)

func ResetDB added in v0.9.4

func ResetDB(d db.Database, c codec.Codec, height int64) error

func SetLastHeight added in v1.2.11

func SetLastHeight(dbase db.Database, c codec.Codec, height int64) error

func UnsafeFinalize added in v1.2.11

func UnsafeFinalize(
	sm ServiceManager,
	c module.Chain,
	blk module.BlockData,
	cancelCh <-chan struct{},
	progressCB module.ProgressCallback,
) error

Types

type Chain added in v0.9.10

type Chain interface {
	Database() db.Database
	Wallet() module.Wallet
	ServiceManager() module.ServiceManager
	NID() int
	CID() int
	GenesisStorage() module.GenesisStorage
	CommitVoteSetDecoder() module.CommitVoteSetDecoder
	Genesis() []byte
}

type LocatorManager added in v1.3.10

type LocatorManager interface {
	GetLocator(id []byte) (*module.TransactionLocator, error)
}

type RefCounter

type RefCounter interface {
	RefCount() int
}

type RefTracer

type RefTracer struct {
	Logger log.Logger
	// contains filtered or unexported fields
}

func (*RefTracer) TraceDispose

func (rt *RefTracer) TraceDispose(rc RefCounter)

func (*RefTracer) TraceNew

func (rt *RefTracer) TraceNew(rc RefCounter)

func (*RefTracer) TraceRef

func (rt *RefTracer) TraceRef(rc RefCounter)

func (*RefTracer) TraceUnref

func (rt *RefTracer) TraceUnref(rc RefCounter)

type ServiceManager added in v0.9.10

type ServiceManager interface {
	module.TransitionManager
	TransactionFromBytes(b []byte, blockVersion int) (module.Transaction, error)
	GetChainID(result []byte) (int64, error)
	GetNetworkID(result []byte) (int64, error)
	GetNextBlockVersion(result []byte) int
	ImportResult(result []byte, vh []byte, src db.Database) error
	GenesisTransactionFromBytes(b []byte, blockVersion int) (module.Transaction, error)
	TransactionListFromHash(hash []byte) module.TransactionList
	ReceiptListFromResult(result []byte, g module.TransactionGroup) (module.ReceiptList, error)
	SendTransaction(result []byte, height int64, tx interface{}) ([]byte, error)
	ValidatorListFromHash(hash []byte) module.ValidatorList
	TransactionListFromSlice(txs []module.Transaction, version int) module.TransactionList
	SendTransactionAndWait(result []byte, height int64, tx interface{}) ([]byte, <-chan interface{}, error)
	WaitTransactionResult(id []byte) (<-chan interface{}, error)
	ExportResult(result []byte, vh []byte, dst db.Database) error
	BTPSectionFromResult(result []byte) (module.BTPSection, error)
	NextProofContextMapFromResult(result []byte) (module.BTPProofContextMap, error)
}

type V2BodyFormat added in v1.3.0

type V2BodyFormat struct {
	PatchTransactions  [][]byte
	NormalTransactions [][]byte
	Votes              []byte
	BTPDigest          []byte
}

func (*V2BodyFormat) RLPDecodeSelf added in v1.3.0

func (bb *V2BodyFormat) RLPDecodeSelf(d codec.Decoder) error

func (*V2BodyFormat) RLPEncodeSelf added in v1.3.0

func (bb *V2BodyFormat) RLPEncodeSelf(e codec.Encoder) error

type V2HeaderFormat added in v1.3.0

type V2HeaderFormat struct {
	Version                int
	Height                 int64
	Timestamp              int64
	Proposer               []byte
	PrevID                 []byte
	VotesHash              []byte
	NextValidatorsHash     []byte
	PatchTransactionsHash  []byte
	NormalTransactionsHash []byte
	LogsBloom              []byte
	Result                 []byte
	NSFilter               []byte
}

func (*V2HeaderFormat) RLPDecodeSelf added in v1.3.0

func (bh *V2HeaderFormat) RLPDecodeSelf(d codec.Decoder) error

func (*V2HeaderFormat) RLPEncodeSelf added in v1.3.0

func (bh *V2HeaderFormat) RLPEncodeSelf(e codec.Encoder) error

Jump to

Keyboard shortcuts

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