From e587fe0d36d49874c0ff03069eac1eded116c687 Mon Sep 17 00:00:00 2001 From: Andrew Sisley Date: Mon, 23 Sep 2024 13:25:04 -0400 Subject: [PATCH] WIP --- internal/core/block/block.go | 16 ++++++++++++++++ net/sync_dag.go | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/internal/core/block/block.go b/internal/core/block/block.go index 1ec62fe939..1daaa1348c 100644 --- a/internal/core/block/block.go +++ b/internal/core/block/block.go @@ -121,6 +121,9 @@ type Encryption struct { type Block struct { // Delta is the CRDT delta that is stored in the block. Delta crdt.CRDT + + Heads []cidlink.Link + // Links are the links to other blocks in the DAG. Links []DAGLink // Encryption contains the encryption information for the block's delta. @@ -142,6 +145,18 @@ func (block *Block) Clone() *Block { } } +func (block *Block) Links2() []cidlink.Link { + result := make([]cidlink.Link, 0, len(block.Heads)+len(block.Links)) + + result = append(result, block.Heads...) + + for _, link := range block.Links { + result = append(result, link.Link) + } + + return result +} + // GetHeadLinks returns the CIDs of the previous blocks. There can be more than 1 with multiple heads. func (block *Block) GetHeadLinks() []cid.Cid { var heads []cid.Cid @@ -160,6 +175,7 @@ func (block *Block) IPLDSchemaBytes() []byte { return []byte(` type Block struct { delta CRDT + heads [Link] links [DAGLink] encryption optional Link } diff --git a/net/sync_dag.go b/net/sync_dag.go index e9c17035bf..e9952a016f 100644 --- a/net/sync_dag.go +++ b/net/sync_dag.go @@ -72,9 +72,9 @@ func loadBlockLinks(ctx context.Context, lsys linking.LinkSystem, block *coreblo cancel() } - for _, lnk := range block.Links { + for _, lnk := range block.Links2() { wg.Add(1) - go func(lnk coreblock.DAGLink) { + go func(lnk cidlink.Link) { defer wg.Done() if ctx.Err() != nil { return