Skip to content
Snippets Groups Projects
Commit 4ba3c353 authored by capossele's avatar capossele
Browse files

:bug: fix FPC frontend bug

parent 17f1c8d8
No related branches found
No related tags found
No related merge requests found
......@@ -22,7 +22,6 @@ import (
"github.com/iotaledger/hive.go/daemon"
"github.com/iotaledger/hive.go/events"
"github.com/iotaledger/hive.go/logger"
"github.com/iotaledger/hive.go/stringify"
"google.golang.org/grpc"
)
......@@ -95,21 +94,21 @@ func configureFPC() {
voter.Events().RoundExecuted.Attach(events.NewClosure(func(roundStats *vote.RoundStats) {
peersQueried := len(roundStats.QueriedOpinions)
voteContextsCount := len(roundStats.ActiveVoteContexts)
var s string
for _, conflict := range roundStats.ActiveVoteContexts {
s += stringify.Struct("VoteContext",
stringify.StructField("ID", conflict.ID),
stringify.StructField("eta", fmt.Sprintf("%.4f", conflict.Liked)),
stringify.StructField("history", fmt.Sprintf("%v", conflict.Opinions)),
stringify.StructField("last opinion", fmt.Sprintf("%d", conflict.LastOpinion())),
)
s += fmt.Sprintf("\nOpinion received:\n")
for _, opinion := range roundStats.QueriedOpinions {
s += fmt.Sprintf("%v - %v\n", opinion.OpinionGiverID, opinion.Opinions[conflict.ID])
}
}
log.Infof("executed round with rand %0.4f for %d vote contexts on %d peers, took %v\n%s", roundStats.RandUsed, voteContextsCount, peersQueried, roundStats.Duration, s)
// var s string
// for _, conflict := range roundStats.ActiveVoteContexts {
// s += stringify.Struct("VoteContext",
// stringify.StructField("ID", conflict.ID),
// stringify.StructField("eta", fmt.Sprintf("%.4f", conflict.Liked)),
// stringify.StructField("history", fmt.Sprintf("%v", conflict.Opinions)),
// stringify.StructField("last opinion", fmt.Sprintf("%d", conflict.LastOpinion())),
// )
// // s += fmt.Sprintf("\nOpinion received:\n")
// // for _, opinion := range roundStats.QueriedOpinions {
// // s += fmt.Sprintf("%v - %v\n", opinion.OpinionGiverID, opinion.Opinions[conflict.ID])
// // }
// }
log.Infof("executed round with rand %0.4f for %d vote contexts on %d peers, took %v", roundStats.RandUsed, voteContextsCount, peersQueried, roundStats.Duration)
}))
}
......
......@@ -121,7 +121,7 @@ func onReceiveMessageFromMessageLayer(cachedMessage *message.CachedMessage, cach
return
}
log.Info("Receive FPCTest Msg - ", fpcTestPayload.ID().String())
//log.Info("Receive FPCTest Msg - ", fpcTestPayload.ID().String())
FPCTangle.AttachPayload(fpcTestPayload)
}
......@@ -130,7 +130,7 @@ func onReceiveMessageFromFPCTest(cachedPayload *fpcTestPayload.CachedPayload, ca
defer cachedMetadata.Release()
id := cachedPayload.Unwrap().ID()
log.Info("Conflict detected - ", id)
//log.Info("Conflict detected - ", id)
var initialOpn vote.Opinion
switch cachedMetadata.Unwrap().IsLiked() {
......@@ -140,7 +140,7 @@ func onReceiveMessageFromFPCTest(cachedPayload *fpcTestPayload.CachedPayload, ca
initialOpn = vote.Dislike
}
log.Infof("submitting %s with initial opinion %d", id, initialOpn)
//log.Infof("submitting %s with initial opinion %d", id, initialOpn)
if err := voter.Vote(id.String(), initialOpn); err != nil {
log.Error(err)
}
......
package dashboard
import (
"fmt"
"time"
"github.com/iotaledger/goshimmer/packages/shutdown"
......@@ -10,12 +11,11 @@ import (
"github.com/iotaledger/hive.go/daemon"
"github.com/iotaledger/hive.go/events"
"github.com/iotaledger/hive.go/workerpool"
"github.com/mr-tron/base58"
)
var (
fpcLiveFeedWorkerCount = 1
fpcLiveFeedWorkerQueueSize = 50
fpcLiveFeedWorkerQueueSize = 200
fpcLiveFeedWorkerPool *workerpool.WorkerPool
conflicts map[string]Conflict
......@@ -49,7 +49,7 @@ func configureFPCLiveFeed() {
func runFPCLiveFeed() {
daemon.BackgroundWorker("Analysis[FPCUpdater]", func(shutdownSignal <-chan struct{}) {
newMsgRateLimiter := time.NewTicker(time.Second / 10)
newMsgRateLimiter := time.NewTicker(time.Second / 100)
defer newMsgRateLimiter.Stop()
onFPCHeartbeatReceived := events.NewClosure(func(hb *packet.FPCHeartbeat) {
......@@ -73,10 +73,11 @@ func runFPCLiveFeed() {
func createFPCUpdate(hb *packet.FPCHeartbeat) *FPCMsg {
update := make(map[string]Conflict)
conflictIds := ""
nodeID := fmt.Sprintf("%x", hb.OwnID[:8])
for ID, context := range hb.RoundStats.ActiveVoteContexts {
conflictIds += fmt.Sprintf("%s - ", ID)
update[ID] = newConflict()
nodeID := base58.Encode(hb.OwnID)
update[ID].NodesView[nodeID] = voteContext{
NodeID: nodeID,
Rounds: context.Rounds,
......@@ -84,6 +85,8 @@ func createFPCUpdate(hb *packet.FPCHeartbeat) *FPCMsg {
}
}
log.Infow("FPC-hb:", "nodeID", nodeID, "conflicts:", conflictIds)
return &FPCMsg{
ConflictSet: update,
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment