Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidBalance = errors.New("invalid balance")
View Source
var ( // ErrNotSelf retruns if the address is not my contraact address ErrNotSelf = errors.New("not self address") )
Functions ¶
Types ¶
type Manager ¶
type Manager interface { // Init the store manager to load the erc20 list Init() error // FindERC20 finds the erc20 code FindERC20(address gethCommon.Address) (*model.ERC20, error) // InsertERC20 inserts the erc20 code InsertERC20(code *model.ERC20) error // InsertTd writes the total difficulty for a block InsertTd(block *types.Block, td *big.Int) error // LatestHeader returns a latest header from db LatestHeader() (*model.Header, error) // GetHeaderByNumber returns the header of the given block number GetHeaderByNumber(number int64) (*model.Header, error) // GetTd returns the TD of the given block hash GetTd(hash []byte) (*model.TotalDifficulty, error) // UpdateBlocks updates all block data. 'delete' indicates whether deletes all data before update. UpdateBlocks(blocks []*types.Block, receipts [][]*types.Receipt, dumps []*state.DirtyDump, events [][]*types.TransferLog, mode UpdateMode) error }
Manager is a wrapper interface to insert block, receipt and states quickly
func NewManager ¶
NewManager news a store manager to insert block, receipts and states.
type ServiceManager ¶
type ServiceManager interface { // Block header store FindBlockByNumber(blockNumber int64) (result *model.Header, err error) FindBlockByHash(hash []byte) (result *model.Header, err error) FindLatestBlock() (result *model.Header, err error) // Transaction store FindTransaction(hash []byte) (result *model.Transaction, err error) FindTransactionsByBlockHash(blockHash []byte) (result []*model.Transaction, err error) // GetBalance returns the amount of wei for the given address in the state of the // given block number. If blockNr < 0, the given block is the latest block. // Noted that the return block number may be different from the input one because // we don't have state in the input one. GetBalance(ctx context.Context, address common.Address, blockNr int64) (balance *big.Int, blockNumber *big.Int, err error) // GetERC20Balance returns the amount of ERC20 token for the given address in the state of the // given block number. If blockNr < 0, the given block is the latest block. // Noted that the return block number may be different from the input one because // we don't have state in the input one. GetERC20Balance(ctx context.Context, contractAddress, address common.Address, blockNr int64) (*decimal.Decimal, *big.Int, error) }
ServiceManager is a wrapper interface that serves data for RPC services.
func NewServiceManager ¶
func NewServiceManager(db *gorm.DB) ServiceManager
NewServiceManager news a service manager to serve data for RPC services.
type UpdateMode ¶
type UpdateMode = int
UpdateMode defines the mode to update blocks
const ( // ModeReOrg represents update blocks by reorg // Stop if any errors occur. ModeReOrg UpdateMode = iota // ModeSync represents update blocks by ethereum sync // Stop if any errors occur, but return nil error if it's a duplicate error ModeSync // ModeForceSync represents update erc20 storage data forcibly // Update all erc20 storage data even if duplicate errors occur. ModeForceSync )
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
mocks
Code generated by mockery v1.0.0
|
Code generated by mockery v1.0.0 |
mocks
Code generated by mockery v1.0.0
|
Code generated by mockery v1.0.0 |
Code generated by mockery v1.0.0 Code generated by mockery v1.0.0
|
Code generated by mockery v1.0.0 Code generated by mockery v1.0.0 |
mocks
Code generated by mockery v1.0.0
|
Code generated by mockery v1.0.0 |
mocks
Code generated by mockery v1.0.0
|
Code generated by mockery v1.0.0 |
Click to show internal directories.
Click to hide internal directories.