lcimporter

package
v1.3.12 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyLastBlockHeight = "block.lastHeight"
	ChanBuf            = 2048
)
View Source
const (
	TransactionsPerBlock = 3_000
	TransactionsToStore  = 4_000
)
View Source
const (
	VarNextBlockHeight = "nextBlockHeight"
	VarLastBlockHeight = "lastBlockHeight"
	VarCurrentMerkle   = "currentMerkleHeader"
)
View Source
const (
	CursorUp  = "\x1b[1A"
	ClearLine = "\x1b[2K"
)
View Source
const CIDOfMainNet = 1
View Source
const ContractPath = "contract"

Variables

View Source
var ErrAfterLastBlock = errors.NewBase(errors.IllegalArgumentError, "AfterLastBlock")
View Source
var ErrCanceled = errors.NewBase(errors.InterruptedError, "Canceled")

Functions

func BlockIndexKey added in v0.9.7

func BlockIndexKey(height int64) []byte

func CheckLogsBloom added in v0.9.10

func CheckLogsBloom(logger log.Logger, e, r module.LogsBloom) error

func CheckReceipt

func CheckReceipt(logger log.Logger, r1, r2 module.Receipt) error

func CheckStatus

func CheckStatus(logger log.Logger, s1, s2 module.Status) error

func D added in v0.9.7

func D(v interface{}) string

func EventLogEqual

func EventLogEqual(e1, e2 module.EventLog) bool

func FeePaymentEqual

func FeePaymentEqual(p1, p2 module.FeePayment) bool

func JSONMarshalIndent

func JSONMarshalIndent(obj interface{}) ([]byte, error)

func NewChain

func NewChain(org module.Chain, dbase db.Database) module.Chain

func NewRegulator

func NewRegulator() module.Regulator

func Statusf

func Statusf(l log.Logger, format string, args ...interface{})

func TimestampToString added in v0.9.7

func TimestampToString(ts int64) string

Types

type BPSMeasure added in v0.9.10

type BPSMeasure struct {
	RateMeasure
	// contains filtered or unexported fields
}

func (*BPSMeasure) GetBPS added in v0.9.10

func (m *BPSMeasure) GetBPS() float32

func (*BPSMeasure) Init added in v0.9.10

func (m *BPSMeasure) Init(cnt int) *BPSMeasure

func (*BPSMeasure) OnBlock added in v0.9.10

func (m *BPSMeasure) OnBlock()

type BasicService added in v0.9.7

type BasicService struct {
	Chain   module.Chain
	Plt     base.Platform
	BaseDir string
	// contains filtered or unexported fields
}

func (*BasicService) FinalizeTransition added in v0.9.7

func (s *BasicService) FinalizeTransition(tr module.Transition, opt int, noFlush bool) error

func (*BasicService) GetNextBlockVersion added in v0.9.10

func (s *BasicService) GetNextBlockVersion(result []byte, vl module.ValidatorList) int

func (*BasicService) NewInitTransition added in v0.9.7

func (s *BasicService) NewInitTransition(
	result []byte, vl module.ValidatorList, logger log.Logger,
) (module.Transition, error)

func (*BasicService) NewSyncTransition added in v0.9.7

func (s *BasicService) NewSyncTransition(tr module.Transition, result []byte,
	vl []byte,
) module.Transition

func (*BasicService) NewTransition added in v0.9.7

func (s *BasicService) NewTransition(
	parent module.Transition, patchtxs module.TransactionList,
	normaltxs module.TransactionList, bi module.BlockInfo,
	csi module.ConsensusInfo, alreadyValidated bool,
) module.Transition

type BlockConverter

type BlockConverter struct {
	module.TraceCallback
	// contains filtered or unexported fields
}

func NewBlockConverter

func NewBlockConverter(c module.Chain, plt base.Platform, pm eeproxy.Manager, cs Store, data string) (*BlockConverter, error)

func NewBlockConverterWithService added in v0.9.7

func NewBlockConverterWithService(
	chain module.Chain,
	plt base.Platform,
	cs Store,
	data string,
	svc Service,
) (*BlockConverter, error)

func (*BlockConverter) GetBlockByHeight added in v0.9.7

func (e *BlockConverter) GetBlockByHeight(h int64) (*blockv1.Block, error)

func (*BlockConverter) GetBlockVotes added in v0.9.10

func (e *BlockConverter) GetBlockVotes(h int64) (*blockv0.BlockVoteList, error)

func (*BlockConverter) GetLastHeight added in v0.9.7

func (e *BlockConverter) GetLastHeight() int64

func (*BlockConverter) OnEnd added in v0.9.7

func (e *BlockConverter) OnEnd(err error)

func (*BlockConverter) OnLog added in v0.9.7

func (e *BlockConverter) OnLog(level module.TraceLevel, msg string)

func (*BlockConverter) Rebase

func (e *BlockConverter) Rebase(from, to int64, firstNForcedResults []*BlockTransaction) (<-chan interface{}, error)

Rebase re-bases blocks and returns a channel of *BlockTransaction or error. ErrAfterLastBlock is sent if from is beyond the last block.

func (*BlockConverter) Start

func (e *BlockConverter) Start(from, to int64) (<-chan interface{}, error)

func (*BlockConverter) Term added in v0.9.7

func (e *BlockConverter) Term()

type BlockTransaction

type BlockTransaction struct {
	Height        int64
	BlockHash     []byte
	Result        []byte
	ValidatorHash []byte
	TXCount       int32
	// contains filtered or unexported fields
}

func (*BlockTransaction) Bytes

func (tx *BlockTransaction) Bytes() []byte

func (*BlockTransaction) ClearCache added in v0.9.7

func (tx *BlockTransaction) ClearCache()

func (*BlockTransaction) Equal

func (tx *BlockTransaction) Equal(object trie.Object) bool

func (*BlockTransaction) Flush added in v0.9.7

func (tx *BlockTransaction) Flush() error

func (*BlockTransaction) From

func (tx *BlockTransaction) From() module.Address

func (*BlockTransaction) GetHandler

func (*BlockTransaction) Group

func (*BlockTransaction) Hash

func (tx *BlockTransaction) Hash() []byte

func (*BlockTransaction) ID

func (tx *BlockTransaction) ID() []byte

func (*BlockTransaction) IsLast added in v0.9.10

func (tx *BlockTransaction) IsLast() bool

func (*BlockTransaction) IsSkippable

func (tx *BlockTransaction) IsSkippable() bool

func (*BlockTransaction) Nonce

func (tx *BlockTransaction) Nonce() *big.Int

func (*BlockTransaction) PreValidate

func (tx *BlockTransaction) PreValidate(wc state.WorldContext, update bool) error

func (*BlockTransaction) RLPDecodeSelf

func (tx *BlockTransaction) RLPDecodeSelf(d codec.Decoder) error

func (*BlockTransaction) RLPEncodeSelf

func (tx *BlockTransaction) RLPEncodeSelf(e codec.Encoder) error

func (*BlockTransaction) Reset added in v0.9.7

func (tx *BlockTransaction) Reset(s db.Database, k []byte) error

func (*BlockTransaction) Resolve added in v0.9.7

func (tx *BlockTransaction) Resolve(builder merkle.Builder) error

func (*BlockTransaction) String added in v0.9.8

func (tx *BlockTransaction) String() string

func (*BlockTransaction) Timestamp

func (tx *BlockTransaction) Timestamp() int64

func (*BlockTransaction) To

func (tx *BlockTransaction) To() module.Address

func (*BlockTransaction) ToJSON

func (tx *BlockTransaction) ToJSON(version module.JSONVersion) (interface{}, error)

func (*BlockTransaction) ValidateNetwork

func (tx *BlockTransaction) ValidateNetwork(nid int) bool

func (*BlockTransaction) Verify

func (tx *BlockTransaction) Verify() error

func (*BlockTransaction) Version

func (tx *BlockTransaction) Version() int

type BlockV1ProofStorage added in v0.9.10

type BlockV1ProofStorage interface {
	GetBlockV1Proof() (*hexary.MerkleHeader, *blockv0.BlockVoteList, error)
	SetBlockV1Proof(root []byte, size int64, votes *blockv0.BlockVoteList) error
}

type Canceler

type Canceler func()

type Config

type Config struct {
	Validators  []*common.Address   `json:"validators"`
	StoreURI    string              `json:"store_uri"`
	MaxRPS      int                 `json:"max_rps"`
	CacheConfig lcstore.CacheConfig `json:"cache_config"`
	BaseDir     string
	Platform    base.Platform
	ProxyMgr    eeproxy.Manager
}

type Executor

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

func NewExecutor

func NewExecutor(chain module.Chain, dbase db.Database, cfg *Config) (*Executor, error)

func NewExecutorWithBC added in v0.9.7

func NewExecutorWithBC(rdb, idb db.Database, logger log.Logger, bc IBlockConverter) (*Executor, error)

func (*Executor) FinalizeBlocks added in v0.9.10

func (e *Executor) FinalizeBlocks(height int64) (*hexary.MerkleHeader, *blockv0.BlockVoteList, error)

func (*Executor) FinalizeTransactions

func (e *Executor) FinalizeTransactions(to int64) error

FinalizeTransactions finalize transactions to the height

func (*Executor) GetMerkleHeader added in v0.9.10

func (e *Executor) GetMerkleHeader(height int64) (*hexary.MerkleHeader, error)

func (*Executor) GetTransactions

func (e *Executor) GetTransactions(from, to int64, callback OnBlockTransactions) (Canceler, error)

GetTransactions get transactions in the range.

func (*Executor) ProposeTransactions

func (e *Executor) ProposeTransactions(from int64) ([]*BlockTransaction, error)

ProposeTransactions propose transactions for blocks to be consensus after finalized.

func (*Executor) Start

func (e *Executor) Start() error

func (*Executor) SyncTransactions

func (e *Executor) SyncTransactions(txs []*BlockTransaction) error

SyncTransactions sync transactions

func (*Executor) Term added in v0.9.7

func (e *Executor) Term()

type GetTPSer

type GetTPSer interface {
	GetTPS() float32
}

type IBlockConverter added in v0.9.7

type IBlockConverter interface {
	Rebase(from, to int64, txs []*BlockTransaction) (<-chan interface{}, error)
	GetBlockVotes(height int64) (*blockv0.BlockVoteList, error)
	Term()
}

type ImportCallback added in v0.9.7

type ImportCallback interface {
	OnResult(err error)
}

type OnBlockTransactions added in v0.9.7

type OnBlockTransactions func([]*BlockTransaction, error)

type RateMeasure

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

func (*RateMeasure) GetRate

func (m *RateMeasure) GetRate(t time.Duration) float32

func (*RateMeasure) Init

func (m *RateMeasure) Init(cnt int) *RateMeasure

func (*RateMeasure) Record

func (m *RateMeasure) Record(t time.Duration, c int64)

type Service added in v0.9.7

type Service interface {
	NewInitTransition(
		result []byte, vl module.ValidatorList, logger log.Logger,
	) (module.Transition, error)
	NewTransition(
		parent module.Transition, patchtxs module.TransactionList,
		normaltxs module.TransactionList, bi module.BlockInfo,
		csi module.ConsensusInfo, alreadyValidated bool,
	) module.Transition
	NewSyncTransition(
		tr module.Transition, result []byte, vl []byte,
	) module.Transition
	FinalizeTransition(tr module.Transition, opt int, noFlush bool) error
	GetNextBlockVersion(result []byte, vl module.ValidatorList) int
}

func NewService added in v0.9.7

func NewService(c module.Chain, plt base.Platform, pm eeproxy.Manager, baseDir string) (Service, error)

type ServiceManager

type ServiceManager struct {
	module.ServiceManager
	// contains filtered or unexported fields
}

func NewServiceManager

func NewServiceManager(chain module.Chain, rdb db.Database, cfg *Config, cb ImportCallback) (*ServiceManager, error)

func NewServiceManagerWithExecutor added in v0.9.7

func NewServiceManagerWithExecutor(chain module.Chain, ex *Executor, ps BlockV1ProofStorage, vs []*common.Address, cb ImportCallback) (*ServiceManager, error)

func (*ServiceManager) AddSyncRequest added in v1.2.9

func (sm *ServiceManager) AddSyncRequest(id db.BucketID, key []byte) error

func (*ServiceManager) BTPDigestFromResult added in v1.3.0

func (sm *ServiceManager) BTPDigestFromResult(result []byte) (module.BTPDigest, error)

func (*ServiceManager) BTPNetworkFromResult added in v1.3.0

func (sm *ServiceManager) BTPNetworkFromResult(result []byte, nid int64) (module.BTPNetwork, error)

func (*ServiceManager) BTPNetworkTypeFromResult added in v1.3.0

func (sm *ServiceManager) BTPNetworkTypeFromResult(result []byte, ntid int64) (module.BTPNetworkType, error)

func (*ServiceManager) BTPSectionFromResult added in v1.3.0

func (sm *ServiceManager) BTPSectionFromResult(result []byte) (module.BTPSection, error)

func (*ServiceManager) Call

func (sm *ServiceManager) Call(result []byte, vl module.ValidatorList, js []byte, bi module.BlockInfo) (interface{}, error)

func (*ServiceManager) CreateInitialTransition

func (sm *ServiceManager) CreateInitialTransition(result []byte, nextValidators module.ValidatorList) (module.Transition, error)

func (*ServiceManager) CreateSyncTransition

func (sm *ServiceManager) CreateSyncTransition(tr module.Transition, result []byte, vlHash []byte, noBuffer bool) module.Transition

func (*ServiceManager) CreateTransition

func (sm *ServiceManager) CreateTransition(parent module.Transition, txs module.TransactionList, bi module.BlockInfo, csi module.ConsensusInfo, validated bool) (module.Transition, error)

func (*ServiceManager) ExecuteTransaction

func (sm *ServiceManager) ExecuteTransaction(result []byte, vh []byte, js []byte, bi module.BlockInfo) (module.Receipt, error)

func (*ServiceManager) ExportResult

func (sm *ServiceManager) ExportResult(result []byte, vh []byte, dst db.Database) error

func (*ServiceManager) Finalize

func (sm *ServiceManager) Finalize(tr module.Transition, opt int) error

func (*ServiceManager) Finished added in v0.9.10

func (sm *ServiceManager) Finished() bool

func (*ServiceManager) GenesisTransactionFromBytes

func (sm *ServiceManager) GenesisTransactionFromBytes(b []byte, blockVersion int) (module.Transaction, error)

func (*ServiceManager) GetAPIInfo

func (sm *ServiceManager) GetAPIInfo(result []byte, addr module.Address) (module.APIInfo, error)

func (*ServiceManager) GetBalance

func (sm *ServiceManager) GetBalance(result []byte, addr module.Address) (*big.Int, error)

func (*ServiceManager) GetChainID

func (sm *ServiceManager) GetChainID(result []byte) (int64, error)

func (*ServiceManager) GetImportedBlocks added in v0.9.7

func (sm *ServiceManager) GetImportedBlocks() int64

func (*ServiceManager) GetMembers

func (sm *ServiceManager) GetMembers(result []byte) (module.MemberList, error)

func (*ServiceManager) GetMinimizeBlockGen

func (sm *ServiceManager) GetMinimizeBlockGen(result []byte) bool

func (*ServiceManager) GetNetworkID

func (sm *ServiceManager) GetNetworkID(result []byte) (int64, error)

func (*ServiceManager) GetNextBlockVersion added in v0.9.8

func (sm *ServiceManager) GetNextBlockVersion(result []byte) int

func (*ServiceManager) GetPatches

func (*ServiceManager) GetRoundLimit

func (sm *ServiceManager) GetRoundLimit(result []byte, vl int) int64

func (*ServiceManager) GetSCOREStatus added in v1.2.11

func (sm *ServiceManager) GetSCOREStatus(result []byte, addr module.Address) (module.SCOREStatus, error)

func (*ServiceManager) GetStatus added in v0.9.10

func (sm *ServiceManager) GetStatus() string

func (*ServiceManager) GetTotalSupply

func (sm *ServiceManager) GetTotalSupply(result []byte) (*big.Int, error)

func (*ServiceManager) HasTransaction

func (sm *ServiceManager) HasTransaction(id []byte) bool

func (*ServiceManager) ImportResult

func (sm *ServiceManager) ImportResult(result []byte, vh []byte, src db.Database) error

func (*ServiceManager) NextProofContextMapFromResult added in v1.3.0

func (sm *ServiceManager) NextProofContextMapFromResult(result []byte) (module.BTPProofContextMap, error)

func (*ServiceManager) PatchTransition

func (*ServiceManager) ProposeTransition

func (sm *ServiceManager) ProposeTransition(parent module.Transition, bi module.BlockInfo, csi module.ConsensusInfo) (ntr module.Transition, ret error)

func (*ServiceManager) ReceiptListFromResult

func (sm *ServiceManager) ReceiptListFromResult(result []byte, g module.TransactionGroup) (module.ReceiptList, error)

func (*ServiceManager) SendPatch

func (sm *ServiceManager) SendPatch(patch module.Patch) error

func (*ServiceManager) SendTransaction

func (sm *ServiceManager) SendTransaction(result []byte, height int64, tx interface{}) ([]byte, error)

func (*ServiceManager) SendTransactionAndWait

func (sm *ServiceManager) SendTransactionAndWait(result []byte, height int64, tx interface{}) ([]byte, <-chan interface{}, error)

func (*ServiceManager) Start

func (sm *ServiceManager) Start()

func (*ServiceManager) Term

func (sm *ServiceManager) Term()

func (*ServiceManager) TransactionFromBytes

func (sm *ServiceManager) TransactionFromBytes(b []byte, blockVersion int) (module.Transaction, error)

func (*ServiceManager) TransactionListFromHash

func (sm *ServiceManager) TransactionListFromHash(hash []byte) module.TransactionList

func (*ServiceManager) TransactionListFromSlice

func (sm *ServiceManager) TransactionListFromSlice(txs []module.Transaction, version int) module.TransactionList

func (*ServiceManager) ValidatorListFromHash

func (sm *ServiceManager) ValidatorListFromHash(hash []byte) module.ValidatorList

func (*ServiceManager) WaitForTransaction

func (sm *ServiceManager) WaitForTransaction(tr module.Transition, bi module.BlockInfo, cb func()) bool

func (*ServiceManager) WaitTransactionResult

func (sm *ServiceManager) WaitTransactionResult(id []byte) (<-chan interface{}, error)

type Store

type Store interface {
	GetRepsByHash(id []byte) (*blockv0.RepsList, error)
	GetBlockByHeight(height int) (blockv0.Block, error)
	GetReceipt(id []byte) (module.Receipt, error)
	GetVotesByHeight(h int) (*blockv0.BlockVoteList, error)
}

type TPSMeasure

type TPSMeasure struct {
	RateMeasure
	// contains filtered or unexported fields
}

func (*TPSMeasure) GetTPS

func (m *TPSMeasure) GetTPS() float32

func (*TPSMeasure) Init

func (m *TPSMeasure) Init(cnt int) *TPSMeasure

func (*TPSMeasure) OnTransactions

func (m *TPSMeasure) OnTransactions(c *big.Int)

type ToJSONer

type ToJSONer interface {
	ToJSON(version module.JSONVersion) (interface{}, error)
}

type Transition

type Transition struct {
	module.Transition
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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