cache misses trigger call out to statediffing geth to fill in the gap in Postgres
This commit is contained in:
+13
-9
@@ -48,19 +48,21 @@ const (
|
||||
|
||||
ETH_DEFAULT_SENDER_ADDR = "ETH_DEFAULT_SENDER_ADDR"
|
||||
ETH_RPC_GAS_CAP = "ETH_RPC_GAS_CAP"
|
||||
ETH_SUPPORTS_STATEDIFF = "ETH_SUPPORTS_STATEDIFF"
|
||||
)
|
||||
|
||||
// Config struct
|
||||
type Config struct {
|
||||
DB *postgres.DB
|
||||
DBConfig postgres.Config
|
||||
WSEndpoint string
|
||||
HTTPEndpoint string
|
||||
IPCEndpoint string
|
||||
ChainConfig *params.ChainConfig
|
||||
DefaultSender *common.Address
|
||||
RPCGasCap *big.Int
|
||||
Client *rpc.Client
|
||||
DB *postgres.DB
|
||||
DBConfig postgres.Config
|
||||
WSEndpoint string
|
||||
HTTPEndpoint string
|
||||
IPCEndpoint string
|
||||
ChainConfig *params.ChainConfig
|
||||
DefaultSender *common.Address
|
||||
RPCGasCap *big.Int
|
||||
Client *rpc.Client
|
||||
SupportStateDiff bool
|
||||
}
|
||||
|
||||
// NewConfig is used to initialize a watcher config from a .toml file
|
||||
@@ -74,6 +76,7 @@ func NewConfig() (*Config, error) {
|
||||
viper.BindEnv("ethereum.httpPath", shared.ETH_HTTP_PATH)
|
||||
viper.BindEnv("ethereum.defaultSender", ETH_DEFAULT_SENDER_ADDR)
|
||||
viper.BindEnv("ethereum.rpcGasCap", ETH_RPC_GAS_CAP)
|
||||
viper.BindEnv("ethereum.supportsStateDiff", ETH_SUPPORTS_STATEDIFF)
|
||||
|
||||
c.DBConfig.Init()
|
||||
|
||||
@@ -83,6 +86,7 @@ func NewConfig() (*Config, error) {
|
||||
return nil, err
|
||||
}
|
||||
c.Client = cli
|
||||
c.SupportStateDiff = viper.GetBool("ethereum.supportsStateDiff")
|
||||
|
||||
wsPath := viper.GetString("server.wsPath")
|
||||
if wsPath == "" {
|
||||
|
||||
@@ -80,6 +80,8 @@ type Service struct {
|
||||
serveWg *sync.WaitGroup
|
||||
// rpc client for forwarding cache misses
|
||||
client *rpc.Client
|
||||
// whether the proxied client supports state diffing
|
||||
supportsStateDiffing bool
|
||||
// backend for the server
|
||||
backend *eth.Backend
|
||||
}
|
||||
@@ -94,6 +96,8 @@ func NewServer(settings *Config) (Server, error) {
|
||||
sap.QuitChan = make(chan bool)
|
||||
sap.Subscriptions = make(map[common.Hash]map[rpc.ID]Subscription)
|
||||
sap.SubscriptionTypes = make(map[common.Hash]eth.SubscriptionSettings)
|
||||
sap.client = settings.Client
|
||||
sap.supportsStateDiffing = settings.SupportStateDiff
|
||||
var err error
|
||||
sap.backend, err = eth.NewEthBackend(sap.db, ð.Config{
|
||||
ChainConfig: settings.ChainConfig,
|
||||
@@ -141,7 +145,7 @@ func (sap *Service) APIs() []rpc.API {
|
||||
return append(apis, rpc.API{
|
||||
Namespace: eth.APIName,
|
||||
Version: eth.APIVersion,
|
||||
Service: eth.NewPublicEthAPI(sap.backend, sap.client),
|
||||
Service: eth.NewPublicEthAPI(sap.backend, sap.client, sap.supportsStateDiffing),
|
||||
Public: true,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user