Adds an entry to the appropriate channels' caches, returning the affected channels. lateSequence flag indicates whether it was a change arriving out of sequence
(ctx context.Context, change *LogEntry)
| 835 | // Adds an entry to the appropriate channels' caches, returning the affected channels. lateSequence |
| 836 | // flag indicates whether it was a change arriving out of sequence |
| 837 | func (c *changeCache) _addToCache(ctx context.Context, change *LogEntry) []channels.ID { |
| 838 | |
| 839 | if change.Sequence >= c.nextSequence { |
| 840 | c.nextSequence = change.Sequence + 1 |
| 841 | } |
| 842 | // check if change is unused sequence range |
| 843 | if change.EndSequence != 0 { |
| 844 | c.nextSequence = change.EndSequence + 1 |
| 845 | } |
| 846 | delete(c.receivedSeqs, change.Sequence) |
| 847 | |
| 848 | // If unused sequence, notify the cache and return |
| 849 | if change.UnusedSequence { |
| 850 | c.channelCache.AddUnusedSequence(change) |
| 851 | return nil |
| 852 | } |
| 853 | |
| 854 | if change.IsPrincipal { |
| 855 | c.channelCache.AddPrincipal(change) |
| 856 | return nil |
| 857 | } |
| 858 | |
| 859 | // updatedChannels tracks the set of channels that should be notified of the change. This includes |
| 860 | // the change's active channels, as well as any channel removals for the active revision. |
| 861 | updatedChannels := c.channelCache.AddToCache(ctx, change) |
| 862 | if base.LogDebugEnabled(ctx, base.KeyChanges) { |
| 863 | base.DebugfCtx(ctx, base.KeyChanges, " #%d ==> channels %v", change.Sequence, base.UD(updatedChannels)) |
| 864 | } |
| 865 | |
| 866 | if change.TimeReceived != 0 { |
| 867 | c.db.DbStats.Database().DCPCachingCount.Add(1) |
| 868 | c.db.DbStats.Database().DCPCachingTime.Add(change.TimeReceived.Since()) |
| 869 | } |
| 870 | |
| 871 | return updatedChannels |
| 872 | } |
| 873 | |
| 874 | // _addPendingLogs Add the first change(s) from pendingLogs if they're the next sequence. If not, and we've been |
| 875 | // waiting too long for nextSequence, move nextSequence to skipped queue. |
no test coverage detected