Skip to content

Commit

Permalink
Merge branch 'feat/cache-reset' of github.com:iotaledger/iota-core in…
Browse files Browse the repository at this point in the history
…to feat/reactive-chainmanager
  • Loading branch information
hmoog committed Nov 7, 2023
2 parents 9e529a4 + e6bfef5 commit df283fb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 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
7 changes: 5 additions & 2 deletions tools/docker-network/run.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash


# Create a function to join an array of strings by a given character
function join { local IFS="$1"; shift; echo "$*"; }

Expand Down Expand Up @@ -52,7 +51,11 @@ docker run --rm \
golang:1.21 go run -tags=rocksdb . --config docker --seed 7R1itJx5hVuo9w9hjg5cwKFmek4HMSoBDgJZN8hKGxih

# Move and set permissions for the .snapshot file
mv -f ../genesis-snapshot/*.snapshot .
if ! mv -f ../genesis-snapshot/*.snapshot .; then
echo "Failed to create or move snapshot file"
exit 1
fi

chmod o+r *.snapshot

echo "Run iota-core network"
Expand Down

0 comments on commit df283fb

Please sign in to comment.