mirror of
https://github.com/anyproto/anytype-heart.git
synced 2025-06-09 17:44:59 +09:00
move build state from cli to debug
This commit is contained in:
parent
6797286be7
commit
05f0573ca0
3 changed files with 336 additions and 13 deletions
|
@ -10,7 +10,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/anytypeio/go-anytype-middleware/change"
|
||||
"github.com/anytypeio/go-anytype-middleware/core/block/editor/state"
|
||||
"github.com/anytypeio/go-anytype-middleware/core/debug/debugtree"
|
||||
"github.com/anytypeio/go-anytype-middleware/pkg/lib/core/smartblock"
|
||||
"github.com/anytypeio/go-anytype-middleware/util/pbtypes"
|
||||
|
@ -71,22 +70,13 @@ func main() {
|
|||
if *printState {
|
||||
fmt.Println("Building state...")
|
||||
stt := time.Now()
|
||||
root := t.Root()
|
||||
if root == nil || root.GetSnapshot() == nil {
|
||||
log.Fatal("root missing or not a snapshot")
|
||||
}
|
||||
s := state.NewDocFromSnapshot("", root.GetSnapshot()).(*state.State)
|
||||
s.SetChangeId(root.Id)
|
||||
st, err := change.BuildStateSimpleCRDT(s, t)
|
||||
s, err := dt.BuildStateByTree(t)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if _, _, err = state.ApplyStateFast(st); err != nil {
|
||||
return
|
||||
log.Fatal("can't build state:", err)
|
||||
}
|
||||
dur := time.Since(stt)
|
||||
fmt.Println(s.StringDebug())
|
||||
sbt, _ := smartblock.SmartBlockTypeFromID(st.RootId())
|
||||
sbt, _ := smartblock.SmartBlockTypeFromID(s.RootId())
|
||||
fmt.Printf("Smarblock type:\t%v\n", sbt.ToProto())
|
||||
fmt.Println("state building time:", dur)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue