mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2025-01-11 09:20:17 +01:00
Do nort send notifications if nothing changed.
This commit is contained in:
parent
29845a259d
commit
51626a1371
@ -31,7 +31,6 @@ func (ct *ChangeTracker) BlockChanged(key []byte) {
|
|||||||
log.Printf("decoding key failed: %s", err)
|
log.Printf("decoding key failed: %s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Printf("changed block: %v", coord)
|
|
||||||
ct.mutex.Lock()
|
ct.mutex.Lock()
|
||||||
ct.changes[quantizedXZ{X: coord.X / 16, Z: coord.Z / 16}] = true
|
ct.changes[quantizedXZ{X: coord.X / 16, Z: coord.Z / 16}] = true
|
||||||
ct.mutex.Unlock()
|
ct.mutex.Unlock()
|
||||||
@ -40,10 +39,17 @@ func (ct *ChangeTracker) BlockChanged(key []byte) {
|
|||||||
func (ct *ChangeTracker) FlushChanges(url string) (err error) {
|
func (ct *ChangeTracker) FlushChanges(url string) (err error) {
|
||||||
log.Println("change flush triggered")
|
log.Println("change flush triggered")
|
||||||
var oldChanges map[quantizedXZ]bool
|
var oldChanges map[quantizedXZ]bool
|
||||||
|
var sendNotification bool
|
||||||
ct.mutex.Lock()
|
ct.mutex.Lock()
|
||||||
oldChanges = ct.changes
|
oldChanges = ct.changes
|
||||||
ct.changes = make(map[quantizedXZ]bool)
|
if len(oldChanges) > 0 {
|
||||||
|
sendNotification = true
|
||||||
|
ct.changes = make(map[quantizedXZ]bool)
|
||||||
|
}
|
||||||
ct.mutex.Unlock()
|
ct.mutex.Unlock()
|
||||||
|
if !sendNotification {
|
||||||
|
return
|
||||||
|
}
|
||||||
go func() {
|
go func() {
|
||||||
changes := make([]quantizedXZ, len(oldChanges))
|
changes := make([]quantizedXZ, len(oldChanges))
|
||||||
i := 0
|
i := 0
|
||||||
|
Loading…
Reference in New Issue
Block a user