increment network serial

This commit is contained in:
Pascal Fischer 2025-06-19 12:14:26 +02:00
parent 0c7cac81f0
commit 4b44b8c46c
3 changed files with 19 additions and 0 deletions

View File

@ -1615,6 +1615,10 @@ func (am *DefaultAccountManager) GetDNSDomain(settings *types.Settings) string {
func (am *DefaultAccountManager) onPeersInvalidated(ctx context.Context, accountID string) { func (am *DefaultAccountManager) onPeersInvalidated(ctx context.Context, accountID string) {
log.WithContext(ctx).Debugf("validated peers has been invalidated for account %s", accountID) log.WithContext(ctx).Debugf("validated peers has been invalidated for account %s", accountID)
err := am.Store.IncrementNetworkSerial(ctx, store.LockingStrengthUpdate, accountID)
if err != nil {
log.Errorf("failed to increment network serial number for account %s: %v", accountID, err)
}
am.BufferUpdateAccountPeers(ctx, accountID) am.BufferUpdateAccountPeers(ctx, accountID)
} }

View File

@ -144,6 +144,10 @@ func (am *DefaultAccountManager) MarkPeerConnected(ctx context.Context, peerPubK
if expired { if expired {
// we need to update other peers because when peer login expires all other peers are notified to disconnect from // we need to update other peers because when peer login expires all other peers are notified to disconnect from
// the expired one. Here we notify them that connection is now allowed again. // the expired one. Here we notify them that connection is now allowed again.
err := am.Store.IncrementNetworkSerial(ctx, store.LockingStrengthUpdate, accountID)
if err != nil {
log.Errorf("failed to increment network serial number for account %s: %v", accountID, err)
}
am.BufferUpdateAccountPeers(ctx, accountID) am.BufferUpdateAccountPeers(ctx, accountID)
} }
@ -270,6 +274,11 @@ func (am *DefaultAccountManager) UpdatePeer(ctx context.Context, accountID, user
inactivityExpirationChanged = true inactivityExpirationChanged = true
} }
err = transaction.IncrementNetworkSerial(ctx, store.LockingStrengthUpdate, accountID)
if err != nil {
return err
}
return transaction.SavePeer(ctx, store.LockingStrengthUpdate, accountID, peer) return transaction.SavePeer(ctx, store.LockingStrengthUpdate, accountID, peer)
}) })
if err != nil { if err != nil {

View File

@ -960,6 +960,12 @@ func (am *DefaultAccountManager) expireAndUpdatePeers(ctx context.Context, accou
) )
} }
// ideally this should run in a transaction
err = am.Store.IncrementNetworkSerial(ctx, store.LockingStrengthUpdate, accountID)
if err != nil {
log.Errorf("failed to increment network serial number for account %s: %v", accountID, err)
}
if len(peerIDs) != 0 { if len(peerIDs) != 0 {
// this will trigger peer disconnect from the management service // this will trigger peer disconnect from the management service
am.peersUpdateManager.CloseChannels(ctx, peerIDs) am.peersUpdateManager.CloseChannels(ctx, peerIDs)