Documentation
¶
Index ¶
- Variables
- type CacheConfig
- type ChainDB
- type StateCache
- func (c *StateCache) AlignPubData(blockSize int)
- func (c *StateCache) GetPendingAccount(accountIndex int64) (*types.AccountInfo, bool)
- func (c *StateCache) GetPendingGas(assetId int64) *big.Int
- func (c *StateCache) GetPendingNft(nftIndex int64) (*nft.L2Nft, bool)
- func (c *StateCache) MarkAccountAssetsDirty(accountIndex int64, assets []int64)
- func (c *StateCache) MarkNftDirty(nftIndex int64)
- func (c *StateCache) SetPendingAccount(accountIndex int64, account *types.AccountInfo)
- func (c *StateCache) SetPendingGas(assetId int64, balanceDelta *big.Int)
- func (c *StateCache) SetPendingNft(nftIndex int64, nft *nft.L2Nft)
- type StateDB
- func (s *StateDB) Close()
- func (s *StateDB) DeepCopyAccounts(accountIds []int64) (map[int64]*types.AccountInfo, error)
- func (s *StateDB) GetAccount(accountIndex int64) (*account.Account, error)
- func (s *StateDB) GetAccountByName(accountName string) (*account.Account, error)
- func (s *StateDB) GetAccountByNameHash(accountNameHash string) (*account.Account, error)
- func (s *StateDB) GetCommittedNonce(accountIndex int64) (int64, error)
- func (s *StateDB) GetFormatAccount(accountIndex int64) (*types.AccountInfo, error)
- func (s *StateDB) GetGasAccountIndex() (int64, error)
- func (s *StateDB) GetGasConfig() (map[uint32]map[int]int64, error)
- func (s *StateDB) GetNextAccountIndex() int64
- func (s *StateDB) GetNextNftIndex() int64
- func (s *StateDB) GetNft(nftIndex int64) (*nft.L2Nft, error)
- func (s *StateDB) GetPendingAccount(blockHeight int64) ([]*account.Account, []*account.AccountHistory, error)
- func (s *StateDB) GetPendingNft(blockHeight int64) ([]*nft.L2Nft, []*nft.L2NftHistory, error)
- func (s *StateDB) GetPendingNonce(accountIndex int64) (int64, error)
- func (s *StateDB) IntermediateRoot(cleanDirty bool) error
- func (s *StateDB) MarkGasAccountAsPending() error
- func (s *StateDB) PrepareAccountsAndAssets(accountAssetsMap map[int64]map[int64]bool) error
- func (s *StateDB) PrepareNft(nftIndex int64) (*nft.L2Nft, error)
- func (s *StateDB) PurgeCache(stateRoot string)
- func (s *StateDB) SyncGasAccountToRedis() error
- func (s *StateDB) SyncStateCacheToRedis() error
Constants ¶
This section is empty.
Variables ¶
var (
DefaultCacheConfig = CacheConfig{
AccountCacheSize: 2048,
NftCacheSize: 2048,
}
)
Functions ¶
This section is empty.
Types ¶
type CacheConfig ¶
type ChainDB ¶
type ChainDB struct { DB *gorm.DB // Block Chain data BlockModel block.BlockModel CompressedBlockModel compressedblock.CompressedBlockModel TxModel tx.TxModel PriorityRequestModel priorityrequest.PriorityRequestModel // State DB AccountModel account.AccountModel AccountHistoryModel account.AccountHistoryModel L2AssetInfoModel asset.AssetModel L2NftModel nft.L2NftModel L2NftHistoryModel nft.L2NftHistoryModel TxPoolModel tx.TxPoolModel // Sys config SysConfigModel sysconfig.SysConfigModel }
func NewChainDB ¶
type StateCache ¶
type StateCache struct { StateRoot string // Updated in executor's GeneratePubData method. PubData []byte PriorityOperations int64 PubDataOffset []uint32 PendingOnChainOperationsPubData [][]byte PendingOnChainOperationsHash []byte Txs []*tx.Tx // Record the flat data that should be updated. PendingAccountMap map[int64]*types.AccountInfo PendingNftMap map[int64]*nft.L2Nft PendingGasMap map[int64]*big.Int //pending gas changes of a block // contains filtered or unexported fields }
func NewStateCache ¶
func NewStateCache(stateRoot string) *StateCache
func (*StateCache) AlignPubData ¶
func (c *StateCache) AlignPubData(blockSize int)
func (*StateCache) GetPendingAccount ¶
func (c *StateCache) GetPendingAccount(accountIndex int64) (*types.AccountInfo, bool)
func (*StateCache) GetPendingGas ¶ added in v0.0.5
func (c *StateCache) GetPendingGas(assetId int64) *big.Int
func (*StateCache) GetPendingNft ¶
func (c *StateCache) GetPendingNft(nftIndex int64) (*nft.L2Nft, bool)
func (*StateCache) MarkAccountAssetsDirty ¶
func (c *StateCache) MarkAccountAssetsDirty(accountIndex int64, assets []int64)
func (*StateCache) MarkNftDirty ¶
func (c *StateCache) MarkNftDirty(nftIndex int64)
func (*StateCache) SetPendingAccount ¶ added in v0.0.4
func (c *StateCache) SetPendingAccount(accountIndex int64, account *types.AccountInfo)
func (*StateCache) SetPendingGas ¶ added in v0.0.5
func (c *StateCache) SetPendingGas(assetId int64, balanceDelta *big.Int)
func (*StateCache) SetPendingNft ¶ added in v0.0.4
func (c *StateCache) SetPendingNft(nftIndex int64, nft *nft.L2Nft)
type StateDB ¶
type StateDB struct { // State cache *StateCache // Flat state AccountCache *lru.Cache NftCache *lru.Cache // Tree state AccountTree bsmt.SparseMerkleTree NftTree bsmt.SparseMerkleTree AccountAssetTrees *tree.AssetTreeCache TreeCtx *tree.Context // contains filtered or unexported fields }
func NewStateDB ¶
func NewStateDBForDryRun ¶
func (*StateDB) DeepCopyAccounts ¶
func (*StateDB) GetAccount ¶
func (*StateDB) GetAccountByName ¶ added in v0.0.4
GetAccountByName get the account by its name. Firstly, try to find the account in the current state cache, it iterates the pending account map, not performance friendly, please take care when use this API. Secondly, if not found in the current state cache, then try to find the account from database.
func (*StateDB) GetAccountByNameHash ¶ added in v0.0.4
GetAccountByNameHash get the account by its name hash. Firstly, try to find the account in the current state cache, it iterates the pending account map, not performance friendly, please take care when use this API. Secondly, if not found in the current state cache, then try to find the account from database.
func (*StateDB) GetCommittedNonce ¶
func (*StateDB) GetFormatAccount ¶
func (s *StateDB) GetFormatAccount(accountIndex int64) (*types.AccountInfo, error)
func (*StateDB) GetGasAccountIndex ¶
func (*StateDB) GetNextAccountIndex ¶
func (*StateDB) GetNextNftIndex ¶
func (*StateDB) GetPendingAccount ¶
func (*StateDB) GetPendingNft ¶
func (*StateDB) GetPendingNonce ¶
func (*StateDB) IntermediateRoot ¶
func (*StateDB) MarkGasAccountAsPending ¶ added in v0.0.5
MarkGasAccountAsPending will mark gas account as pending account. Putting gas account is pending account will unify many codes and remove some tricky logics.