Skip to content
Snippets Groups Projects
Commit 06cc0182 authored by Levente Pap's avatar Levente Pap
Browse files

Add DBStats method to msg layer tangle

parent 45850860
No related branches found
No related tags found
No related merge requests found
......@@ -135,6 +135,25 @@ func (tangle *Tangle) Prune() error {
return nil
}
// DBStats returns the number of solid messages and total number of messages in the database, furthermore the average time it takes to solidify messages.
func (tangle *Tangle) DBStats() (solidCount int, messageCount int, avgSolidificationTime float64) {
var sumSolidificationTime time.Duration
tangle.messageMetadataStorage.ForEach(func(key []byte, cachedObject objectstorage.CachedObject) bool {
defer cachedObject.Release()
cachedMessageMetadata := &CachedMessageMetadata{CachedObject: cachedObject}
msgMetaData := cachedMessageMetadata.Unwrap()
messageCount++
received := msgMetaData.ReceivedTime()
if msgMetaData.IsSolid() {
solidCount++
sumSolidificationTime += msgMetaData.solidificationTime.Sub(received)
}
return true
})
avgSolidificationTime = float64(sumSolidificationTime.Milliseconds()) / float64(solidCount)
return
}
// worker that stores the message and calls the corresponding storage events.
func (tangle *Tangle) storeMessageWorker(msg *message.Message) {
// store message
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment