aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-06-22 17:01:27 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-06-24 23:34:04 +0800
commit43e4a6501beb42bc0f4fffcbcb1e3f5fe58b6062 (patch)
treef89773dd13c08c3c9dca00808cdeff28f49db1e1 /core
parent7bd71fa80071f86ca86ed7ef64ab51c88cabe7d4 (diff)
downloaddexon-43e4a6501beb42bc0f4fffcbcb1e3f5fe58b6062.tar
dexon-43e4a6501beb42bc0f4fffcbcb1e3f5fe58b6062.tar.gz
dexon-43e4a6501beb42bc0f4fffcbcb1e3f5fe58b6062.tar.bz2
dexon-43e4a6501beb42bc0f4fffcbcb1e3f5fe58b6062.tar.lz
dexon-43e4a6501beb42bc0f4fffcbcb1e3f5fe58b6062.tar.xz
dexon-43e4a6501beb42bc0f4fffcbcb1e3f5fe58b6062.tar.zst
dexon-43e4a6501beb42bc0f4fffcbcb1e3f5fe58b6062.zip
core, ethdb: instrument the block and state db
Conflicts: ethdb/database.go
Diffstat (limited to 'core')
-rw-r--r--core/chain_manager.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/core/chain_manager.go b/core/chain_manager.go
index 6a017b63f..b87f65893 100644
--- a/core/chain_manager.go
+++ b/core/chain_manager.go
@@ -13,6 +13,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
@@ -30,6 +31,10 @@ var (
blockNumPre = []byte("block-num-")
blockInsertTimer = metrics.GetOrRegisterTimer("core/BlockInsertions", metrics.DefaultRegistry)
+ blockdbGetMeter = metrics.GetOrRegisterMeter("core/blockdb/Gets", metrics.DefaultRegistry)
+ blockdbPutMeter = metrics.GetOrRegisterMeter("core/blockdb/Puts", metrics.DefaultRegistry)
+ statedbGetMeter = metrics.GetOrRegisterMeter("core/statedb/Gets", metrics.DefaultRegistry)
+ statedbPutMeter = metrics.GetOrRegisterMeter("core/statedb/Puts", metrics.DefaultRegistry)
)
const (
@@ -121,7 +126,15 @@ func NewChainManager(genesis *types.Block, blockDb, stateDb common.Database, pow
cache: NewBlockCache(blockCacheLimit),
pow: pow,
}
-
+ // Instrument the block and state databases
+ if db, ok := blockDb.(*ethdb.LDBDatabase); ok {
+ db.GetMeter = blockdbGetMeter
+ db.PutMeter = blockdbPutMeter
+ }
+ if db, ok := stateDb.(*ethdb.LDBDatabase); ok {
+ db.GetMeter = statedbGetMeter
+ db.PutMeter = statedbPutMeter
+ }
// Check the genesis block given to the chain manager. If the genesis block mismatches block number 0
// throw an error. If no block or the same block's found continue.
if g := bc.GetBlockByNumber(0); g != nil && g.Hash() != genesis.Hash() {