func (r *updateRollup) FlushBuffer() {
	r.buffer.Lock()

	if len(r.buffer.updates) == 0 {
		r.logger.Debug("no updates flushed")
		r.buffer.Unlock()
		return
	}

	now := time.Now()

	r.timings.Lock()

	sinceFirstUpdate := time.Duration(0)
	if !r.timings.lastUpdate.IsZero() {
		sinceFirstUpdate = r.timings.lastUpdate.Sub(r.timings.firstUpdate)
	}

	sinceLastFlush := time.Duration(0)
	if !r.timings.lastFlush.IsZero() {
		sinceLastFlush = now.Sub(r.timings.lastFlush)
	}

	r.logger.WithFields(log.Fields{
		"checksum":         r.node.memberlist.Checksum(),
		"sinceFirstUpdate": sinceFirstUpdate,
		"sinceLastFlush":   sinceLastFlush,
		"numUpdates":       r.numUpdates(),
		"updates":          r.buffer,
	}).Debug("rollup flushed update buffer")

	r.buffer.updates = make(map[string][]Change)
	r.timings.lastFlush = now
	r.timings.firstUpdate = util.TimeZero()
	r.timings.lastUpdate = util.TimeZero()

	r.buffer.Unlock()
	r.timings.Unlock()
}
func (s *RollupTestSuite) TestTrackUpdatesFlushes() {
	s.r.buffer.Lock()
	s.r.buffer.updates["one"] = []Change{}
	s.r.buffer.updates["two"] = []Change{}
	s.r.buffer.Unlock()

	s.Len(s.r.Buffer(), 2, "expected two updates to be in buffer")

	s.r.timings.lastUpdate = util.TimeZero() // simulate time passing

	s.r.TrackUpdates([]Change{Change{Address: "new"}})

	s.Len(s.r.Buffer(), 1, "expected one change")
}