mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-21 04:53:14 -06:00
Change to using default prevEntryIDs for initial relay query
This commit is contained in:
parent
5aa6b47a64
commit
41cd9d256e
|
|
@ -30,7 +30,9 @@ func (r *RelayInternalAPI) PerformRelayServerSync(
|
||||||
userID gomatrixserverlib.UserID,
|
userID gomatrixserverlib.UserID,
|
||||||
relayServer gomatrixserverlib.ServerName,
|
relayServer gomatrixserverlib.ServerName,
|
||||||
) error {
|
) error {
|
||||||
prevEntry := gomatrixserverlib.RelayEntry{EntryID: -1}
|
// Providing a default RelayEntry (EntryID = 0) is done to ask the relay if there are any
|
||||||
|
// transactions available for this node.
|
||||||
|
prevEntry := gomatrixserverlib.RelayEntry{}
|
||||||
asyncResponse, err := r.fedClient.P2PGetTransactionFromRelay(ctx, userID, prevEntry, relayServer)
|
asyncResponse, err := r.fedClient.P2PGetTransactionFromRelay(ctx, userID, prevEntry, relayServer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf("P2PGetTransactionFromRelay: %s", err.Error())
|
logrus.Errorf("P2PGetTransactionFromRelay: %s", err.Error())
|
||||||
|
|
@ -38,7 +40,9 @@ func (r *RelayInternalAPI) PerformRelayServerSync(
|
||||||
}
|
}
|
||||||
r.processTransaction(&asyncResponse.Txn)
|
r.processTransaction(&asyncResponse.Txn)
|
||||||
|
|
||||||
|
prevEntry = gomatrixserverlib.RelayEntry{EntryID: asyncResponse.EntryID}
|
||||||
for asyncResponse.EntriesQueued {
|
for asyncResponse.EntriesQueued {
|
||||||
|
// There are still more entries available for this node from the relay.
|
||||||
logrus.Infof("Retrieving next entry from relay, previous: %v", prevEntry)
|
logrus.Infof("Retrieving next entry from relay, previous: %v", prevEntry)
|
||||||
asyncResponse, err = r.fedClient.P2PGetTransactionFromRelay(ctx, userID, prevEntry, relayServer)
|
asyncResponse, err = r.fedClient.P2PGetTransactionFromRelay(ctx, userID, prevEntry, relayServer)
|
||||||
prevEntry = gomatrixserverlib.RelayEntry{EntryID: asyncResponse.EntryID}
|
prevEntry = gomatrixserverlib.RelayEntry{EntryID: asyncResponse.EntryID}
|
||||||
|
|
@ -82,7 +86,7 @@ func (r *RelayInternalAPI) QueryTransactions(
|
||||||
previousEntry gomatrixserverlib.RelayEntry,
|
previousEntry gomatrixserverlib.RelayEntry,
|
||||||
) (api.QueryRelayTransactionsResponse, error) {
|
) (api.QueryRelayTransactionsResponse, error) {
|
||||||
logrus.Infof("QueryTransactions for %s", userID.Raw())
|
logrus.Infof("QueryTransactions for %s", userID.Raw())
|
||||||
if previousEntry.EntryID >= 0 {
|
if previousEntry.EntryID > 0 {
|
||||||
logrus.Infof("Cleaning previous entry (%v) from db for %s",
|
logrus.Infof("Cleaning previous entry (%v) from db for %s",
|
||||||
previousEntry.EntryID,
|
previousEntry.EntryID,
|
||||||
userID.Raw(),
|
userID.Raw(),
|
||||||
|
|
@ -109,7 +113,7 @@ func (r *RelayInternalAPI) QueryTransactions(
|
||||||
response.EntriesQueued = true
|
response.EntriesQueued = true
|
||||||
} else {
|
} else {
|
||||||
logrus.Infof("No more entries in the queue for %s", userID.Raw())
|
logrus.Infof("No more entries in the queue for %s", userID.Raw())
|
||||||
response.EntryID = -1
|
response.EntryID = 0
|
||||||
response.EntriesQueued = false
|
response.EntriesQueued = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ func GetTransactionFromRelay(
|
||||||
) util.JSONResponse {
|
) util.JSONResponse {
|
||||||
logrus.Infof("Handling relay_txn for %s", userID.Raw())
|
logrus.Infof("Handling relay_txn for %s", userID.Raw())
|
||||||
|
|
||||||
previousEntry := gomatrixserverlib.RelayEntry{EntryID: -1}
|
previousEntry := gomatrixserverlib.RelayEntry{}
|
||||||
if err := json.Unmarshal(fedReq.Content(), &previousEntry); err == nil {
|
if err := json.Unmarshal(fedReq.Content(), &previousEntry); err == nil {
|
||||||
logrus.Infof("Previous entry provided: %v", previousEntry.EntryID)
|
logrus.Infof("Previous entry provided: %v", previousEntry.EntryID)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue