aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2022-05-30 15:11:48 +0100
committerNeil Alexander <neilalexander@users.noreply.github.com>2022-05-30 15:11:48 +0100
commit9f8b3136b225b888b5e5e680a425545367584639 (patch)
tree6679dc60b6dd9bec3eac8b8f269f0ab1146ef44a
parentfb52b6cedcd35b43f799f99767c5c9e01876dd5e (diff)
Fix bugs in `resolve-state` tool
-rw-r--r--cmd/resolve-state/main.go23
1 files changed, 11 insertions, 12 deletions
diff --git a/cmd/resolve-state/main.go b/cmd/resolve-state/main.go
index 26f25b9e..6ed6ebdb 100644
--- a/cmd/resolve-state/main.go
+++ b/cmd/resolve-state/main.go
@@ -9,6 +9,7 @@ import (
"strings"
"github.com/matrix-org/dendrite/internal/caching"
+ "github.com/matrix-org/dendrite/roomserver/state"
"github.com/matrix-org/dendrite/roomserver/storage"
"github.com/matrix-org/dendrite/roomserver/types"
"github.com/matrix-org/dendrite/setup"
@@ -59,25 +60,23 @@ func main() {
panic(err)
}
- blockNIDs, err := roomserverDB.StateBlockNIDs(ctx, snapshotNIDs)
- if err != nil {
- panic(err)
- }
+ stateres := state.NewStateResolution(roomserverDB, &types.RoomInfo{
+ RoomVersion: gomatrixserverlib.RoomVersion(*roomVersion),
+ })
- var stateEntries []types.StateEntryList
- for _, list := range blockNIDs {
- entries, err2 := roomserverDB.StateEntries(ctx, list.StateBlockNIDs)
- if err2 != nil {
- panic(err2)
+ var stateEntries []types.StateEntry
+ for _, snapshotNID := range snapshotNIDs {
+ var entries []types.StateEntry
+ entries, err = stateres.LoadStateAtSnapshot(ctx, snapshotNID)
+ if err != nil {
+ panic(err)
}
stateEntries = append(stateEntries, entries...)
}
var eventNIDs []types.EventNID
for _, entry := range stateEntries {
- for _, e := range entry.StateEntries {
- eventNIDs = append(eventNIDs, e.EventNID)
- }
+ eventNIDs = append(eventNIDs, entry.EventNID)
}
fmt.Println("Fetching", len(eventNIDs), "state events")