Documentation ¶
Index ¶
Constants ¶
const ( // FuzzModeDrop is a mode in which we randomly drop reads/writes, connections or sleep FuzzModeDrop = iota // FuzzModeDelay is a mode in which we randomly sleep FuzzModeDelay // LogFormatPlain is a format for colored text LogFormatPlain = "plain" // LogFormatJSON is a format for json output LogFormatJSON = "json" // DefaultLogLevel defines a default log level as INFO. DefaultLogLevel = "info" // Mempool versions. V1 is prioritized mempool (deprecated), v0 is regular mempool. // Default is v0. MempoolV0 = "v0" MempoolV1 = "v1" )
const ( Default = "default" PolygonMumbai = "polygon-mumbai" Polygon = "polygon" Eth = "eth" BSC = "bsc" EthNative = "eth" EvmDecimal = 18 BscNative = "bnb" PolygonNative = "matic" EthNetwork = "ethereum" BscNetwork = "bsc" PolygonNetwork = "polygon" WETH = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" WMATIC = "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270" WBNB = "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c" WhaleUsd = 50000 AddressTypeAccount = 1 AddressTypeToken = 2 ZeroAddress = "0x0000000000000000000000000000000000000000" RangeH24 = "h24" RangeD7 = "d7" RangeD30 = "d30" AssetExpireTime = 2 * 3600 * 1000 AnalyzeTop7 = 7 FeePrecision = 6 TopNum = 300 DefaultDecimals = 18 WhaleNum = 500 WhaleTxDay = 7 MevFront = "front run" UrlPrefix = "https://static.blockpi.io/" OtherCoinUrl = "https://static.blockpi.io/coins-logo/others.svg" Abi = "" /* 401-byte string literal not displayed */ )
const ( MaxPage = math.MaxInt32 MinPage = 1 DefaultPerPage = 10 MaxPerPage = 1000 CreateInBatches = 1000 MinPerPage = 0 OrderAsc = 1 OrderDesc = -1 )
const ( ModeLocal = "local" ModeDevnet = "devnet" ModeTestnet = "testnet" ModeMainnet = "mainnet" )
const ( AaAccountTypeBundler = "bundler" AaAccountTypePaymaster = "paymaster" AaAccountTypeFactory = "factory" AaAccountTypeEntryPoint = "entry_point" AaAccountTypeAA = "aa" )
const DefaultDirPerm = 0700
DefaultDirPerm is the default permissions used when creating directories.
const TokenTypeBase = "base"
Variables ¶
var (
DefaultHomeDir = ".aim"
)
var ERC_4337_ABI string
var ERC_4337_ABI_V07 string
var HandleOpsMap = map[string]string{
"0x1fad948c": "0.6",
"0x765e827f": "0.7",
}
Functions ¶
func EnsureRoot ¶
func EnsureRoot(rootDir string)
EnsureRoot creates the root, config, and data directories if they don't exist, and panics if it fails.
func WriteConfigFile ¶
WriteConfigFile renders config using the template and writes it to configFilePath.
Types ¶
type ApiConfig ¶
type ApiConfig struct { RootDir string `mapstructure:"home" toml:"home"` // TCP or UNIX socket address for the RPC server to listen on ListenAddress string `mapstructure:"laddr" toml:"laddr"` // A list of origins a cross-domain request can be executed from. // If the special '*' value is present in the list, all origins will be allowed. // An origin may contain a wildcard (*) to replace 0 or more characters (i.e.: http://*.domain.com). // Only one wildcard can be used per origin. CORSAllowedOrigins []string `mapstructure:"cors_allowed_origins" toml:"cors_allowed_origins"` // A list of methods the client is allowed to use with cross-domain requests. CORSAllowedMethods []string `mapstructure:"cors_allowed_methods" toml:"cors_allowed_methods"` // A list of non simple headers the client is allowed to use with cross-domain requests. CORSAllowedHeaders []string `mapstructure:"cors_allowed_headers" toml:"cors_allowed_headers"` CORSAllowedCredentials bool `mapstructure:"cors_allowed_credentials" toml:"cors_allowed_credentials"` CORSAMaxAge int `mapstructure:"cors_max_age" toml:"cors_max_age"` // Activate unsafe RPC commands like /dial_persistent_peers and /unsafe_flush_mempool Unsafe bool `mapstructure:"unsafe" toml:"unsafe"` // Maximum number of simultaneous connections (including WebSocket). // Does not include gRPC connections. See grpc_max_open_connections // If you want to accept a larger number than the default, make sure // you increase your OS limits. // 0 - unlimited. // Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files} // 1024 - 40 - 10 - 50 = 924 = ~900 MaxOpenConnections int `mapstructure:"max_open_connections" toml:"max_open_connections"` // Maximum number of unique clientIDs that can /subscribe // If you're using /broadcast_tx_commit, set to the estimated maximum number // of broadcast_tx_commit calls per block. MaxSubscriptionClients int `mapstructure:"max_subscription_clients" toml:"max_subscription_clients"` // Maximum number of unique queries a given client can /subscribe to // If you're using GRPC (or Local RPC client) and /broadcast_tx_commit, set // to the estimated maximum number of broadcast_tx_commit calls per block. MaxSubscriptionsPerClient int `mapstructure:"max_subscriptions_per_client" toml:"max_subscriptions_per_client"` // The number of events that can be buffered per subscription before // returning `ErrOutOfCapacity`. SubscriptionBufferSize int `mapstructure:"experimental_subscription_buffer_size" toml:"experimental_subscription_buffer_size"` // The maximum number of responses that can be buffered per WebSocket // client. If clients cannot read from the WebSocket endpoint fast enough, // they will be disconnected, so increasing this parameter may reduce the // chances of them being disconnected (but will cause the node to use more // memory). // // Must be at least the same as `SubscriptionBufferSize`, otherwise // connections may be dropped unnecessarily. WebSocketWriteBufferSize int `mapstructure:"experimental_websocket_write_buffer_size" toml:"experimental_websocket_write_buffer_size"` // If a WebSocket client cannot read fast enough, at present we may // silently drop events instead of generating an error or disconnecting the // client. // // Enabling this parameter will cause the WebSocket connection to be closed // instead if it cannot read fast enough, allowing for greater // predictability in subscription behavior. CloseOnSlowClient bool `mapstructure:"experimental_close_on_slow_client" toml:"experimental_close_on_slow_client"` // Maximum size of request body, in bytes MaxBodyBytes int64 `mapstructure:"max_body_bytes" toml:"max_body_bytes"` // Maximum size of request header, in bytes MaxHeaderBytes int `mapstructure:"max_header_bytes" toml:"max_header_bytes"` // The path to a file containing certificate that is used to create the HTTPS server. // Might be either absolute path or path related to aaexplorer config directory. // // If the certificate is signed by a certificate authority, // the certFile should be the concatenation of the server's certificate, any intermediates, // and the CA's certificate. // // NOTE: both tls_cert_file and tls_key_file must be present for aaexplorer to create HTTPS server. // Otherwise, HTTP server is run. TLSCertFile string `mapstructure:"tls_cert_file" toml:"tls_cert_file"` // The path to a file containing matching private key that is used to create the HTTPS server. // Might be either absolute path or path related to aaexplorer config directory. // // NOTE: both tls_cert_file and tls_key_file must be present for aaexplorer to create HTTPS server. // Otherwise, HTTP server is run. TLSKeyFile string `mapstructure:"tls_key_file" toml:"tls_key_file"` // no set no enable. // /debug/pprof/ PprofPrefix string `mapstructure:"pprof_prefix" toml:"pprof_prefix"` Prefork bool `mapstructure:"prefork" toml:"prefork"` }
ApiConfig defines the configuration options for the API server
func DefaultApiConfig ¶
func DefaultApiConfig() *ApiConfig
DefaultApiConfig returns a default configuration for the RPC server
func (*ApiConfig) ValidateBasic ¶
ValidateBasic performs basic validation (checking param bounds, etc.) and returns an error if any check fails.
type BaseConfig ¶
type BaseConfig struct { // The root directory for all data. // This should be set in viper so it can unmarshal into this struct RootDir string `mapstructure:"home" toml:"home"` // Output format: 'plain' (colored text) or 'json' LogFormat string `mapstructure:"log_format" toml:"log_format"` // Output level for logging LogLevel string `mapstructure:"log_level" toml:"log_level"` MoralisApiKey string `mapstructure:"moralis_api_key" toml:"moralis_api_key"` Mode string `mapstructure:"mode" toml:"mode"` }
BaseConfig defines the base configuration
func DefaultBaseConfig ¶
func DefaultBaseConfig() BaseConfig
DefaultBaseConfig returns a default base configuration
func (BaseConfig) IsLocal ¶
func (cfg BaseConfig) IsLocal() bool
func (BaseConfig) ValidateBasic ¶
func (cfg BaseConfig) ValidateBasic() error
ValidateBasic performs basic validation (checking param bounds, etc.) and returns an error if any check fails.
type Config ¶
type Config struct { // Top level options use an anonymous struct BaseConfig `mapstructure:",squash" toml:",squash"` // Options for services Api *ApiConfig `mapstructure:"api" toml:"api"` Databases []*DbConfig `mapstructure:"databases" toml:"databases"` EvmParser *EvmParserConfig `mapstructure:"evmparser" toml:"evmparser"` MemoCache *MemoConfig `mapstructure:"memoCache" toml:"memoCache"` Task *TaskConfig `mapstructure:"task" toml:"task" json:"task"` }
func (*Config) CheckDeprecated ¶
func (*Config) ValidateBasic ¶
ValidateBasic performs basic validation (checking param bounds, etc.) and returns an error if any check fails.
type DbConfig ¶
type DbConfig struct { Group string `mapstructure:"group" toml:"group"` Schema *ent.SchemaConfig `mapstructure:"schema" toml:"schema"` Type string `mapstructure:"type" toml:"type"` Host string `mapstructure:"host" toml:"host"` Port int `mapstructure:"port" toml:"port"` User string `mapstructure:"user" toml:"user"` Pass string `mapstructure:"pass" toml:"pass"` Name string `mapstructure:"name" toml:"name"` ApplicationName string `mapstructure:"applicationName" toml:"applicationName"` MaxIdleCount int `mapstructure:"maxIdleCount" toml:"maxIdleCount"` MaxOpenConns int `mapstructure:"maxOpenConns" toml:"maxOpenConns"` MaxLifetime int64 `mapstructure:"maxLifetime" toml:"maxLifetime"` Debug bool `mapstructure:"debug" toml:"debug"` AutoStart bool `mapstructure:"autoStart" toml:"autoStart"` SslMode string `mapstructure:"sslMode" toml:"sslMode"` }
func DefaultDatabaseConfig ¶
func DefaultDatabaseConfig() []*DbConfig
func (DbConfig) ValidateBasic ¶
type EvmParserConfig ¶
type EvmParserConfig struct { StartBlock map[string]int64 `mapstructure:"startBlock" toml:"startBlock"` // -1 start by latest , 0 start by first , >0 start by set Multi int `mapstructure:"multi" toml:"multi"` Batch int `mapstructure:"batch" toml:"batch"` }
func DefaultEvmParserConfig ¶
func DefaultEvmParserConfig() *EvmParserConfig
func (*EvmParserConfig) GetAbi ¶
func (c *EvmParserConfig) GetAbi(version string) string
type MemoConfig ¶
type MemoConfig struct { // NumCounters determines the number of counters (keys) to keep that hold // access frequency information. It's generally a good idea to have more // counters than the max cache capacity, as this will improve eviction // accuracy and subsequent hit ratios. // // For example, if you expect your cache to hold 1,000,000 items when full, // NumCounters should be 10,000,000 (10x). Each counter takes up roughly // 3 bytes (4 bits for each counter * 4 copies plus about a byte per // counter for the bloom filter). Note that the number of counters is // internally rounded up to the nearest power of 2, so the space usage // may be a little larger than 3 bytes * NumCounters. NumCounters int64 // MaxCost can be considered as the cache capacity, in whatever units you // choose to use. // // For example, if you want the cache to have a max capacity of 100MB, you // would set MaxCost to 100,000,000 and pass an item's number of bytes as // the `cost` parameter for calls to Set. If new items are accepted, the // eviction process will take care of making room for the new item and not // overflowing the MaxCost value. MaxCost int64 // BufferItems determines the size of Get buffers. // // Unless you have a rare use case, using `64` as the BufferItems value // results in good performance. BufferItems int64 // Metrics determines whether cache statistics are kept during the cache's // lifetime. There *is* some overhead to keeping statistics, so you should // only set this flag to true when testing or throughput performance isn't a // major factor. Metrics bool // IgnoreInternalCost set to true indicates to the cache that the cost of // internally storing the value should be ignored. This is useful when the // cost passed to set is not using bytes as units. Keep in mind that setting // this to true will increase the memory usage. IgnoreInternalCost bool }
MemoConfig is passed to NewCache for creating new Cache instances.
func DefaultMemoCacheConfig ¶
func DefaultMemoCacheConfig() *MemoConfig
type TaskConfig ¶
type TaskConfig struct { Networks []string `mapstructure:"networks" toml:"networks" json:"networks"` BlockScanThreads int `mapstructure:"blockScanThreads" toml:"blockScanThreads" json:"blockScanThreads"` }
TaskConfig defines the configuration options for the Task
func DefaultTaskConfig ¶
func DefaultTaskConfig() *TaskConfig
DefaultTaskConfig returns a default configuration for the Task
func (TaskConfig) GetBlockScanThreads ¶
func (cfg TaskConfig) GetBlockScanThreads() int