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

Measure FPC number of currently active conflicts

parent 9ec292ce
No related branches found
No related tags found
No related merge requests found
package metrics
import (
"sync/atomic"
"github.com/iotaledger/goshimmer/packages/vote"
)
var activeConflicts uint64
func processRoundStats(stats vote.RoundStats) {
// get the number of active conflicts
numActive := (uint64)(len(stats.ActiveVoteContexts))
atomic.StoreUint64(&activeConflicts, numActive)
}
// ActiveConflicts returns the number of currently active conflicts.
func ActiveConflicts() uint64 {
return atomic.LoadUint64(&activeConflicts)
}
package metrics
import (
"testing"
"github.com/magiconair/properties/assert"
)
func TestActiveConflicts(t *testing.T) {
// initialized to 0
assert.Equal(t, ActiveConflicts(), (uint64)(0))
}
......@@ -6,11 +6,11 @@ import (
"github.com/iotaledger/goshimmer/dapps/valuetransfers"
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/payload"
valuetangle "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/tangle"
"github.com/iotaledger/goshimmer/packages/binary/messagelayer/message"
"github.com/iotaledger/goshimmer/packages/binary/messagelayer/tangle"
"github.com/iotaledger/goshimmer/packages/metrics"
"github.com/iotaledger/goshimmer/packages/shutdown"
"github.com/iotaledger/goshimmer/packages/vote"
"github.com/iotaledger/goshimmer/plugins/messagelayer"
"github.com/iotaledger/hive.go/daemon"
"github.com/iotaledger/hive.go/events"
......@@ -48,6 +48,11 @@ func configure(_ *node.Plugin) {
increaseReceivedTPSCounter()
}))
// FPC round executed
valuetransfers.Voter().Events().RoundExecuted.Attach(events.NewClosure(func(roundStats vote.RoundStats) {
processRoundStats(roundStats)
}))
//// Events coming from metrics package ////
metrics.Events().FPCInboundBytes.Attach(events.NewClosure(func(amountBytes uint64) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment