mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-10 07:58:22 -05:00
Reduce JSON-RPC queries (#6221)
* Delete unused client property * Only update the logs every 5 minutes * Merge branch 'master' into reduce-json-rpc-calls * Merge refs/heads/master into reduce-json-rpc-calls * Merge refs/heads/master into reduce-json-rpc-calls * PR feedback from @nisdas * gofmt * Merge branch 'reduce-json-rpc-calls' of github.com:prysmaticlabs/prysm into reduce-json-rpc-calls
This commit is contained in:
@@ -242,7 +242,6 @@ func TestBlockNumberByTimestamp(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
web3Service = setDefaultMocks(web3Service)
|
||||
web3Service.client = nil
|
||||
|
||||
ctx := context.Background()
|
||||
bn, err := web3Service.BlockNumberByTimestamp(ctx, 150000 /* time */)
|
||||
|
||||
@@ -120,7 +120,6 @@ type Service struct {
|
||||
processingLock sync.RWMutex
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc
|
||||
client Client
|
||||
headerChan chan *gethTypes.Header
|
||||
headTicker *time.Ticker
|
||||
httpEndpoint string
|
||||
@@ -295,11 +294,6 @@ func (s *Service) LatestBlockHash() common.Hash {
|
||||
return bytesutil.ToBytes32(s.latestEth1Data.BlockHash)
|
||||
}
|
||||
|
||||
// Client for interacting with the ETH1.0 chain.
|
||||
func (s *Service) Client() Client {
|
||||
return s.client
|
||||
}
|
||||
|
||||
// AreAllDepositsProcessed determines if all the logs from the deposit contract
|
||||
// are processed.
|
||||
func (s *Service) AreAllDepositsProcessed() (bool, error) {
|
||||
@@ -378,7 +372,6 @@ func (s *Service) initializeConnection(
|
||||
rpcClient *gethRPC.Client,
|
||||
contractCaller *contracts.DepositContractCaller,
|
||||
) {
|
||||
s.client = httpClient
|
||||
s.httpLogger = httpClient
|
||||
s.blockFetcher = httpClient
|
||||
s.depositContractCaller = contractCaller
|
||||
@@ -535,7 +528,7 @@ func (s *Service) handleETH1FollowDistance() {
|
||||
// (analyzed the time of the block from 2018-09-01 to 2019-02-13)
|
||||
fiveMinutesTimeout := roughtime.Now().Add(-5 * time.Minute)
|
||||
// check that web3 client is syncing
|
||||
if time.Unix(int64(s.latestEth1Data.BlockTime), 0).Before(fiveMinutesTimeout) && roughtime.Now().Second()%15 == 0 {
|
||||
if time.Unix(int64(s.latestEth1Data.BlockTime), 0).Before(fiveMinutesTimeout) {
|
||||
log.Warn("eth1 client is not syncing")
|
||||
}
|
||||
if !s.chainStartData.Chainstarted {
|
||||
@@ -613,9 +606,6 @@ func (s *Service) run(done <-chan struct{}) {
|
||||
|
||||
s.initPOWService()
|
||||
|
||||
ticker := time.NewTicker(1 * time.Second)
|
||||
defer ticker.Stop()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-done:
|
||||
@@ -631,7 +621,6 @@ func (s *Service) run(done <-chan struct{}) {
|
||||
continue
|
||||
}
|
||||
s.processBlockHeader(head)
|
||||
case <-ticker.C:
|
||||
s.handleETH1FollowDistance()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user