Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:iotaledger/iota-core into feat/c…
Browse files Browse the repository at this point in the history
…ache-reset
  • Loading branch information
hmoog committed Nov 7, 2023
2 parents 731be8d + 1f4ed11 commit e887145
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docker-network-health.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@ jobs:
- name: Cleanup
run: |
cd ./tools/docker-network
docker compose kill
docker compose down -v
docker compose kill || true
docker compose down -t 1 -v || true
23 changes: 13 additions & 10 deletions pkg/protocol/engine/tipmanager/v1/tipmanager.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package tipmanagerv1

import (
"fmt"

"github.com/iotaledger/hive.go/ds/randommap"
"github.com/iotaledger/hive.go/ds/shrinkingmap"
"github.com/iotaledger/hive.go/lo"
Expand Down Expand Up @@ -148,25 +150,26 @@ func (t *TipManager) setupBlockMetadata(tipMetadata *TipMetadata) {

// forEachParentByType iterates through the parents of the given block and calls the consumer for each parent.
func (t *TipManager) forEachParentByType(block *blocks.Block, consumer func(parentType iotago.ParentsType, parentMetadata *TipMetadata)) {
if block == nil || block.ProtocolBlock() == nil {
return
}

for _, parent := range block.ParentsWithType() {
if metadataStorage := t.metadataStorage(parent.ID.Slot()); metadataStorage != nil {
// Make sure we don't add rootblocks back to the tips.
// Make sure we don't add root blocks back to the tips.
parentBlock, exists := t.retrieveBlock(parent.ID)

if !exists || parentBlock.IsRootBlock() {
continue
}

if parentMetadata, created := metadataStorage.GetOrCreate(parent.ID, func() *TipMetadata { return NewBlockMetadata(parentBlock) }); parentMetadata.Block() != nil {
consumer(parent.Type, parentMetadata)
if parentBlock.ModelBlock() == nil {
fmt.Printf(">> parentBlock exists, but parentBlock.ProtocolBlock() == nil\n ParentBlock: %s\n Block: %s\n", parentBlock.String(), block.String())
}

parentMetadata, created := metadataStorage.GetOrCreate(parent.ID, func() *TipMetadata { return NewBlockMetadata(parentBlock) })
consumer(parent.Type, parentMetadata)

if created {
t.setupBlockMetadata(parentMetadata)
}
if created {
t.setupBlockMetadata(parentMetadata)
}

}
}
}
Expand Down

0 comments on commit e887145

Please sign in to comment.