Skip to content

Commit

Permalink
Reduce JSON-RPC queries (#6221)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
prestonvanloon committed Jun 12, 2020
1 parent 1a6edbb commit 8976249
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
1 change: 0 additions & 1 deletion beacon-chain/powchain/block_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 */)
Expand Down
13 changes: 1 addition & 12 deletions beacon-chain/powchain/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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:
Expand All @@ -631,7 +621,6 @@ func (s *Service) run(done <-chan struct{}) {
continue
}
s.processBlockHeader(head)
case <-ticker.C:
s.handleETH1FollowDistance()
}
}
Expand Down

0 comments on commit 8976249

Please sign in to comment.