Skip to content

Commit

Permalink
Feat: added solidity stuff to the logging - let's see
Browse files Browse the repository at this point in the history
  • Loading branch information
hmoog committed Nov 30, 2023
1 parent a524987 commit ff87a2e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/protocol/engine/blockdag/inmemoryblockdag/blockdag.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package inmemoryblockdag

import (
"fmt"
"sync/atomic"

"github.com/iotaledger/hive.go/ds"
"github.com/iotaledger/hive.go/ierrors"
"github.com/iotaledger/hive.go/runtime/event"
"github.com/iotaledger/hive.go/runtime/module"
Expand Down Expand Up @@ -74,6 +76,8 @@ func (b *BlockDAG) setupBlock(block *blocks.Block) {
var unsolidParentsCount atomic.Int32
unsolidParentsCount.Store(int32(len(block.Parents())))

unsolidParents := ds.NewSet[iotago.BlockID]()

block.ForEachParent(func(parent iotago.Parent) {
parentBlock, exists := b.blockCache.Block(parent.ID)
if !exists {
Expand All @@ -82,7 +86,13 @@ func (b *BlockDAG) setupBlock(block *blocks.Block) {
return
}

unsolidParents.Add(parent.ID)
fmt.Println("unsolid Parents of ", block.ID(), unsolidParents)

parentBlock.Solid().OnUpdateOnce(func(_ bool, _ bool) {
unsolidParents.Delete(parent.ID)
fmt.Println("unsolid Parents of ", block.ID(), unsolidParents)

if unsolidParentsCount.Add(-1) == 0 {
if block.SetSolid() {
b.events.BlockSolid.Trigger(block)
Expand Down

0 comments on commit ff87a2e

Please sign in to comment.