aboutsummaryrefslogtreecommitdiffstats
path: root/ethdb/database.go
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 /ethdb/database.go
parent7bd71fa80071f86ca86ed7ef64ab51c88cabe7d4 (diff)
downloadgo-tangerine-43e4a6501beb42bc0f4fffcbcb1e3f5fe58b6062.tar.gz
go-tangerine-43e4a6501beb42bc0f4fffcbcb1e3f5fe58b6062.tar.zst
go-tangerine-43e4a6501beb42bc0f4fffcbcb1e3f5fe58b6062.zip
core, ethdb: instrument the block and state db
Conflicts: ethdb/database.go
Diffstat (limited to 'ethdb/database.go')
-rw-r--r--ethdb/database.go19
1 files changed, 14 insertions, 5 deletions
diff --git a/ethdb/database.go b/ethdb/database.go
index 5faf8c4e0..48cb37f7c 100644
--- a/ethdb/database.go
+++ b/ethdb/database.go
@@ -4,6 +4,7 @@ import (
"github.com/ethereum/go-ethereum/compression/rle"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/rcrowley/go-metrics"
"github.com/syndtr/goleveldb/leveldb"
"github.com/syndtr/goleveldb/leveldb/errors"
"github.com/syndtr/goleveldb/leveldb/iterator"
@@ -13,10 +14,11 @@ import (
var OpenFileLimit = 64
type LDBDatabase struct {
- // filename for reporting
- fn string
- // LevelDB instance
- db *leveldb.DB
+ fn string // filename for reporting
+ db *leveldb.DB // LevelDB instance
+
+ GetMeter metrics.Meter // Meter for measuring the database get requests
+ PutMeter metrics.Meter // Meter for measuring the database put requests
}
// NewLDBDatabase returns a LevelDB wrapped object. LDBDatabase does not persist data by
@@ -43,7 +45,11 @@ func NewLDBDatabase(file string) (*LDBDatabase, error) {
// Put puts the given key / value to the queue
func (self *LDBDatabase) Put(key []byte, value []byte) error {
- return self.db.Put(key, rle.Compress(value), nil)
+ dat := rle.Compress(value)
+ if self.PutMeter != nil {
+ self.PutMeter.Mark(int64(len(dat)))
+ }
+ return self.db.Put(key, dat, nil)
}
// Get returns the given key if it's present.
@@ -52,6 +58,9 @@ func (self *LDBDatabase) Get(key []byte) ([]byte, error) {
if err != nil {
return nil, err
}
+ if self.GetMeter != nil {
+ self.GetMeter.Mark(int64(len(dat)))
+ }
return rle.Decompress(dat)
}