本文整理匯總了Golang中github.com/ethereum/go-ethereum/metrics.NewTimer函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewTimer函數的具體用法?Golang NewTimer怎麽用?Golang NewTimer使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了NewTimer函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Meter
// Meter configures the database metrics collectors and
func (self *LDBDatabase) Meter(prefix string) {
// Initialize all the metrics collector at the requested prefix
self.getTimer = metrics.NewTimer(prefix + "user/gets")
self.putTimer = metrics.NewTimer(prefix + "user/puts")
self.delTimer = metrics.NewTimer(prefix + "user/dels")
self.missMeter = metrics.NewMeter(prefix + "user/misses")
self.readMeter = metrics.NewMeter(prefix + "user/reads")
self.writeMeter = metrics.NewMeter(prefix + "user/writes")
self.compTimeMeter = metrics.NewMeter(prefix + "compact/time")
self.compReadMeter = metrics.NewMeter(prefix + "compact/input")
self.compWriteMeter = metrics.NewMeter(prefix + "compact/output")
// Create a quit channel for the periodic collector and run it
self.quitLock.Lock()
self.quitChan = make(chan chan error)
self.quitLock.Unlock()
go self.meter(3 * time.Second)
}
示例2:
"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"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/pow"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie"
"github.com/hashicorp/golang-lru"
)
var (
chainlogger = logger.NewLogger("CHAIN")
jsonlogger = logger.NewJsonLogger()
blockInsertTimer = metrics.NewTimer("chain/inserts")
ErrNoGenesis = errors.New("Genesis not found in chain")
)
const (
headerCacheLimit = 512
bodyCacheLimit = 256
tdCacheLimit = 1024
blockCacheLimit = 256
maxFutureBlocks = 256
maxTimeFutureBlocks = 30
)
type BlockChain struct {
chainDb ethdb.Database
示例3: New
func New(config *Config) (*Ethereum, error) {
// Bootstrap database
logger.New(config.DataDir, config.LogFile, config.Verbosity)
if len(config.LogJSON) > 0 {
logger.NewJSONsystem(config.DataDir, config.LogJSON)
}
// Let the database take 3/4 of the max open files (TODO figure out a way to get the actual limit of the open files)
const dbCount = 3
ethdb.OpenFileLimit = 128 / (dbCount + 1)
newdb := config.NewDB
if newdb == nil {
newdb = func(path string) (common.Database, error) { return ethdb.NewLDBDatabase(path) }
}
blockDb, err := newdb(filepath.Join(config.DataDir, "blockchain"))
if err != nil {
return nil, fmt.Errorf("blockchain db err: %v", err)
}
if db, ok := blockDb.(*ethdb.LDBDatabase); ok {
db.GetTimer = metrics.NewTimer("eth/db/block/user/gets")
db.PutTimer = metrics.NewTimer("eth/db/block/user/puts")
db.MissMeter = metrics.NewMeter("eth/db/block/user/misses")
db.ReadMeter = metrics.NewMeter("eth/db/block/user/reads")
db.WriteMeter = metrics.NewMeter("eth/db/block/user/writes")
db.CompTimeMeter = metrics.NewMeter("eth/db/block/compact/time")
db.CompReadMeter = metrics.NewMeter("eth/db/block/compact/input")
db.CompWriteMeter = metrics.NewMeter("eth/db/block/compact/output")
}
stateDb, err := newdb(filepath.Join(config.DataDir, "state"))
if err != nil {
return nil, fmt.Errorf("state db err: %v", err)
}
if db, ok := stateDb.(*ethdb.LDBDatabase); ok {
db.GetTimer = metrics.NewTimer("eth/db/state/user/gets")
db.PutTimer = metrics.NewTimer("eth/db/state/user/puts")
db.MissMeter = metrics.NewMeter("eth/db/state/user/misses")
db.ReadMeter = metrics.NewMeter("eth/db/state/user/reads")
db.WriteMeter = metrics.NewMeter("eth/db/state/user/writes")
db.CompTimeMeter = metrics.NewMeter("eth/db/state/compact/time")
db.CompReadMeter = metrics.NewMeter("eth/db/state/compact/input")
db.CompWriteMeter = metrics.NewMeter("eth/db/state/compact/output")
}
extraDb, err := newdb(filepath.Join(config.DataDir, "extra"))
if err != nil {
return nil, fmt.Errorf("extra db err: %v", err)
}
if db, ok := extraDb.(*ethdb.LDBDatabase); ok {
db.GetTimer = metrics.NewTimer("eth/db/extra/user/gets")
db.PutTimer = metrics.NewTimer("eth/db/extra/user/puts")
db.MissMeter = metrics.NewMeter("eth/db/extra/user/misses")
db.ReadMeter = metrics.NewMeter("eth/db/extra/user/reads")
db.WriteMeter = metrics.NewMeter("eth/db/extra/user/writes")
db.CompTimeMeter = metrics.NewMeter("eth/db/extra/compact/time")
db.CompReadMeter = metrics.NewMeter("eth/db/extra/compact/input")
db.CompWriteMeter = metrics.NewMeter("eth/db/extra/compact/output")
}
nodeDb := filepath.Join(config.DataDir, "nodes")
// Perform database sanity checks
d, _ := blockDb.Get([]byte("ProtocolVersion"))
protov := int(common.NewValue(d).Uint())
if protov != config.ProtocolVersion && protov != 0 {
path := filepath.Join(config.DataDir, "blockchain")
return nil, fmt.Errorf("Database version mismatch. Protocol(%d / %d). `rm -rf %s`", protov, config.ProtocolVersion, path)
}
saveProtocolVersion(blockDb, config.ProtocolVersion)
glog.V(logger.Info).Infof("Protocol Version: %v, Network Id: %v", config.ProtocolVersion, config.NetworkId)
if !config.SkipBcVersionCheck {
b, _ := blockDb.Get([]byte("BlockchainVersion"))
bcVersion := int(common.NewValue(b).Uint())
if bcVersion != config.BlockChainVersion && bcVersion != 0 {
return nil, fmt.Errorf("Blockchain DB version mismatch (%d / %d). Run geth upgradedb.\n", bcVersion, config.BlockChainVersion)
}
saveBlockchainVersion(blockDb, config.BlockChainVersion)
}
glog.V(logger.Info).Infof("Blockchain DB Version: %d", config.BlockChainVersion)
eth := &Ethereum{
shutdownChan: make(chan bool),
databasesClosed: make(chan bool),
blockDb: blockDb,
stateDb: stateDb,
extraDb: extraDb,
eventMux: &event.TypeMux{},
accountManager: config.AccountManager,
DataDir: config.DataDir,
etherbase: common.HexToAddress(config.Etherbase),
clientVersion: config.Name, // TODO should separate from Name
ethVersionId: config.ProtocolVersion,
netVersionId: config.NetworkId,
NatSpec: config.NatSpec,
MinerThreads: config.MinerThreads,
SolcPath: config.SolcPath,
AutoDAG: config.AutoDAG,
GpoMinGasPrice: config.GpoMinGasPrice,
GpoMaxGasPrice: config.GpoMaxGasPrice,
GpoFullBlockRatio: config.GpoFullBlockRatio,
GpobaseStepDown: config.GpobaseStepDown,
//.........這裏部分代碼省略.........
示例4:
//
// go-ethereum is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// go-ethereum is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
// Contains the metrics collected by the fetcher.
package fetcher
import (
"github.com/ethereum/go-ethereum/metrics"
)
var (
announceMeter = metrics.NewMeter("eth/sync/RemoteAnnounces")
announceTimer = metrics.NewTimer("eth/sync/LocalAnnounces")
broadcastMeter = metrics.NewMeter("eth/sync/RemoteBroadcasts")
broadcastTimer = metrics.NewTimer("eth/sync/LocalBroadcasts")
discardMeter = metrics.NewMeter("eth/sync/DiscardedBlocks")
futureMeter = metrics.NewMeter("eth/sync/FutureBlocks")
)
示例5:
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
// Contains the metrics collected by the downloader.
package downloader
import (
"github.com/ethereum/go-ethereum/metrics"
)
var (
hashInMeter = metrics.NewMeter("eth/downloader/hashes/in")
hashReqTimer = metrics.NewTimer("eth/downloader/hashes/req")
hashDropMeter = metrics.NewMeter("eth/downloader/hashes/drop")
hashTimeoutMeter = metrics.NewMeter("eth/downloader/hashes/timeout")
blockInMeter = metrics.NewMeter("eth/downloader/blocks/in")
blockReqTimer = metrics.NewTimer("eth/downloader/blocks/req")
blockDropMeter = metrics.NewMeter("eth/downloader/blocks/drop")
blockTimeoutMeter = metrics.NewMeter("eth/downloader/blocks/timeout")
headerInMeter = metrics.NewMeter("eth/downloader/headers/in")
headerReqTimer = metrics.NewTimer("eth/downloader/headers/req")
headerDropMeter = metrics.NewMeter("eth/downloader/headers/drop")
headerTimeoutMeter = metrics.NewMeter("eth/downloader/headers/timeout")
bodyInMeter = metrics.NewMeter("eth/downloader/bodies/in")
bodyReqTimer = metrics.NewTimer("eth/downloader/bodies/req")