code: func NewAccountingMetrics(r metrics.Registry, d time.Duration, path string) *AccountingMetrics {
  	var val = make([]byte, 8)
  	var err error
  
  	//Create the LevelDB
  	db, err := leveldb.OpenFile(path, nil)
  	if err != nil {
  		log.Error(err.Error())
  		return nil
  	}
  
  	//Check for all defined metrics that there is a value in the DB
  	//If there is, assign it to the metric. This means that the node
  	//has been running before and that metrics have been persisted.
  	metricsMap := map[string]metrics.Counter{
  		"account.balance.credit": mBalanceCredit,
  		"account.balance.debit":  mBalanceDebit,
  		"account.bytes.credit":   mBytesCredit,
  		"account.bytes.debit":    mBytesDebit,
  		"account.msg.credit":     mMsgCredit,
  		"account.msg.debit":      mMsgDebit,
  		"account.peerdrops":      mPeerDrops,
  		"account.selfdrops":      mSelfDrops,
  	}
  	//iterate the map and get the values
  	for key, metric := range metricsMap {
  		val, err = db.Get([]byte(key), nil)
  		//until the first time a value is being written,
  		//this will return an error.
  		//it could be beneficial though to log errors later,
  		//but that would require a different logic
  		if err == nil {
  			metric.Inc(int64(binary.BigEndian.Uint64(val)))
  		}
  	}
  
  	//create the reporter
  	rep := &reporter{
  		reg:      r,
  		interval: d,
  		db:       db,
  		quit:     make(chan struct{}),
  		done:     make(chan struct{}),
  	}
  
  	//run the go routine
  	go rep.run()
  
  	m := &AccountingMetrics{
  		reporter: rep,
  	}
  
  	return m
  }
docs: //NewMetricsDB creates a new LevelDB instance used to persist metrics defined
  //inside p2p/protocols/accounting.go