Skip to content

Commit

Permalink
quaistats.go -> fixed bug where avg gas was using wrong cache
Browse files Browse the repository at this point in the history
  • Loading branch information
hubchub committed May 5, 2023
1 parent c9b5791 commit ef8d86b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions quaistats/quaistats.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ func (s uncleStats) MarshalJSON() ([]byte, error) {

func (s *Service) computeAvgGasPerSec(block *types.Block) uint64 {
var parentTime, parentGasPerSec uint64
if parentCached, ok := s.tpsLookupCache.Get(block.ParentHash()); ok {
if parentCached, ok := s.gasLookupCache.Get(block.ParentHash()); ok {
parentTime = parentCached.(blockAvgGasPerSecCacheDto).Time
parentGasPerSec = parentCached.(blockAvgGasPerSecCacheDto).AvgGasPerSec
} else {
Expand Down Expand Up @@ -654,7 +654,7 @@ func (s *Service) computeAvgGasPerSec(block *types.Block) uint64 {
blockGasPerSec = ((c_alpha-1)*parentGasPerSec + instantGas) / c_alpha
}

s.tpsLookupCache.Add(block.Hash(), blockAvgGasPerSecCacheDto{
s.gasLookupCache.Add(block.Hash(), blockAvgGasPerSecCacheDto{
AvgGasPerSec: blockGasPerSec,
Time: block.Time(),
})
Expand Down

0 comments on commit ef8d86b

Please sign in to comment.