Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Commit

Permalink
fixing tree again
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMarstonConnell committed Jul 1, 2024
1 parent d101724 commit 276b89f
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions jprov/server/ipfs_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 276b89f

Please sign in to comment.