From 276b89f7911e41497feaa7ad18cf736ea777956a Mon Sep 17 00:00:00 2001 From: marston Date: Mon, 1 Jul 2024 14:57:57 -0400 Subject: [PATCH] fixing tree again --- jprov/server/ipfs_upgrade.go | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/jprov/server/ipfs_upgrade.go b/jprov/server/ipfs_upgrade.go index 60b5d93..9ebb75b 100644 --- a/jprov/server/ipfs_upgrade.go +++ b/jprov/server/ipfs_upgrade.go @@ -2,11 +2,15 @@ package server import ( "encoding/hex" + "encoding/json" "errors" "fmt" "log/slog" "strconv" + "github.com/wealdtech/go-merkletree" + "github.com/wealdtech/go-merkletree/v2/sha3" + merkletree2 "github.com/wealdtech/go-merkletree/v2" storageTypes "github.com/jackalLabs/canine-chain/v3/x/storage/types" @@ -45,9 +49,25 @@ func (f *FileServer) migrateToIpfs(activeDeal storageTypes.LegacyActiveDeals) er if err != nil { return fmt.Errorf("failed to decode merkle | %w", err) } - var t interface{} = tree - mt := t.(*merkletree2.MerkleTree) - err = f.ipfsArchive.WriteTreeToDisk(merkle, activeDeal.Signee, startBlock, mt) + e, err := tree.Export() + if err != nil { + return fmt.Errorf("failed to temp export tree | %w", err) + } + var me merkletree.Export + err = json.Unmarshal(e, &me) + if err != nil { + return fmt.Errorf("failed to temp re-import tree | %w", err) + } + + t, err := merkletree2.NewTree( + merkletree2.WithData(me.Data), + merkletree2.WithHashType(sha3.New512()), + merkletree2.WithSalt(me.Salt), + ) + if err != nil { + return err + } + err = f.ipfsArchive.WriteTreeToDisk(merkle, activeDeal.Signee, startBlock, t) if err != nil { return err }