diff options
author | kegsay <kegan@matrix.org> | 2023-05-02 15:03:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-02 15:03:16 +0100 |
commit | f5b3144dc33ddcb2ab161323d422cab257d04b4c (patch) | |
tree | 07d3b03944d2529d96c29674a96c3e76a76ae3b9 /cmd | |
parent | 696cbb70b8cc8d663f7bb7c7a5f25cd57ea6803e (diff) |
Use PDU not *Event in HeaderedEvent (#3073)
Requires https://github.com/matrix-org/gomatrixserverlib/pull/376
This has numerous upsides:
- Less type casting to `*Event` is required.
- Making Dendrite work with `PDU` interfaces means we can swap out Event
impls more easily.
- Tests which represent weird event shapes are easier to write.
Part of a series of refactors on GMSL.
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/resolve-state/main.go | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/cmd/resolve-state/main.go b/cmd/resolve-state/main.go index b2f4afa8..1278b1cc 100644 --- a/cmd/resolve-state/main.go +++ b/cmd/resolve-state/main.go @@ -96,9 +96,9 @@ func main() { panic(err) } - events := make(map[types.EventNID]*gomatrixserverlib.Event, len(eventEntries)) + events := make(map[types.EventNID]gomatrixserverlib.PDU, len(eventEntries)) for _, entry := range eventEntries { - events[entry.EventNID] = entry.Event + events[entry.EventNID] = entry.PDU } if len(removed) > 0 { @@ -155,9 +155,9 @@ func main() { } authEventIDMap := make(map[string]struct{}) - events := make([]*gomatrixserverlib.Event, len(eventEntries)) + events := make([]gomatrixserverlib.PDU, len(eventEntries)) for i := range eventEntries { - events[i] = eventEntries[i].Event + events[i] = eventEntries[i].PDU for _, authEventID := range eventEntries[i].AuthEventIDs() { authEventIDMap[authEventID] = struct{}{} } @@ -174,17 +174,15 @@ func main() { panic(err) } - authEvents := make([]*gomatrixserverlib.Event, len(authEventEntries)) + authEvents := make([]gomatrixserverlib.PDU, len(authEventEntries)) for i := range authEventEntries { - authEvents[i] = authEventEntries[i].Event + authEvents[i] = authEventEntries[i].PDU } fmt.Println("Resolving state") var resolved Events resolved, err = gomatrixserverlib.ResolveConflicts( - gomatrixserverlib.RoomVersion(*roomVersion), - gomatrixserverlib.ToPDUs(events), - gomatrixserverlib.ToPDUs(authEvents), + gomatrixserverlib.RoomVersion(*roomVersion), events, authEvents, ) if err != nil { panic(err) |