From f15c806415b072e347098d48ceff17e4343cbf76 Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Wed, 6 Jul 2022 23:35:43 +0200 Subject: [PATCH] Fix some bugs --- data/threadbuilder/invalidsnapshotexample.yml | 1 + data/threadbuilder/keychain.go | 12 +++++++----- data/threadbuilder/threadbuildergraph_nix.go | 10 +++++++++- data/treebuilder.go | 2 +- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/data/threadbuilder/invalidsnapshotexample.yml b/data/threadbuilder/invalidsnapshotexample.yml index fff71365..317e575b 100644 --- a/data/threadbuilder/invalidsnapshotexample.yml +++ b/data/threadbuilder/invalidsnapshotexample.yml @@ -120,3 +120,4 @@ graph: maybeHeads: - A.1.3 - B.1.2 + diff --git a/data/threadbuilder/keychain.go b/data/threadbuilder/keychain.go index be3119ab..501fb404 100644 --- a/data/threadbuilder/keychain.go +++ b/data/threadbuilder/keychain.go @@ -25,11 +25,13 @@ type Keychain struct { func NewKeychain() *Keychain { return &Keychain{ - SigningKeys: map[string]threadmodels.SigningPrivKey{}, - EncryptionKeys: map[string]threadmodels.EncryptionPrivKey{}, - GeneratedIdentities: map[string]string{}, - ReadKeys: map[string]*SymKey{}, - coder: threadmodels.NewEd25519Decoder(), + SigningKeys: map[string]threadmodels.SigningPrivKey{}, + SigningKeysByIdentity: map[string]threadmodels.SigningPrivKey{}, + EncryptionKeys: map[string]threadmodels.EncryptionPrivKey{}, + GeneratedIdentities: map[string]string{}, + ReadKeys: map[string]*SymKey{}, + ReadKeysByHash: map[uint64]*SymKey{}, + coder: threadmodels.NewEd25519Decoder(), } } diff --git a/data/threadbuilder/threadbuildergraph_nix.go b/data/threadbuilder/threadbuildergraph_nix.go index d3d188b7..30722a53 100644 --- a/data/threadbuilder/threadbuildergraph_nix.go +++ b/data/threadbuilder/threadbuildergraph_nix.go @@ -9,6 +9,8 @@ package threadbuilder import ( "fmt" + "github.com/anytypeio/go-anytype-infrastructure-experiments/data/pb" + "github.com/gogo/protobuf/proto" "strings" "unicode" @@ -42,7 +44,13 @@ func (t *ThreadBuilder) Graph() (string, error) { var chSymbs []string if r.changesDataDecrypted != nil { - for _, chc := range r.changesDataDecrypted.Content { + res := &pb.PlainTextChangeData{} + err := proto.Unmarshal(r.changesDataDecrypted, res) + if err != nil { + return err + } + + for _, chc := range res.Content { tp := fmt.Sprintf("%T", chc.Value) tp = strings.Replace(tp, "ChangeContentValueOf", "", 1) res := "" diff --git a/data/treebuilder.go b/data/treebuilder.go index 97054699..3bcdda49 100644 --- a/data/treebuilder.go +++ b/data/treebuilder.go @@ -44,7 +44,7 @@ func (tb *TreeBuilder) Init() { } func (tb *TreeBuilder) Build(fromStart bool) (*Tree, error) { - heads := tb.thread.Heads() + heads := tb.thread.MaybeHeads() if fromStart { if err := tb.buildTreeFromStart(heads); err != nil {