fix: rebase issues

This commit is contained in:
Richard Ramos 2021-11-06 09:50:38 -04:00
parent 2cbedf47a0
commit a46881fc27
3 changed files with 9 additions and 16 deletions

View File

@ -109,7 +109,7 @@ func (d *DBStore) cleanOlderRecords() error {
// Delete older messages // Delete older messages
if d.maxDuration > 0 { if d.maxDuration > 0 {
sqlStmt := `DELETE FROM message WHERE receiverTimestamp < ?` sqlStmt := `DELETE FROM message WHERE receiverTimestamp < ?`
_, err := d.db.Exec(sqlStmt, utils.GetUnixEpochFrom(func() time.Time { return time.Now().Add(-d.maxDuration) })) _, err := d.db.Exec(sqlStmt, utils.GetUnixEpochFrom(time.Now().Add(-d.maxDuration)))
if err != nil { if err != nil {
return err return err
} }

View File

@ -9,7 +9,6 @@ import (
_ "github.com/mattn/go-sqlite3" // Blank import to register the sqlite3 driver _ "github.com/mattn/go-sqlite3" // Blank import to register the sqlite3 driver
"github.com/status-im/go-waku/tests" "github.com/status-im/go-waku/tests"
"github.com/status-im/go-waku/waku/v2/protocol/pb" "github.com/status-im/go-waku/waku/v2/protocol/pb"
"github.com/status-im/go-waku/waku/v2/utils"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
@ -59,24 +58,18 @@ func TestStoreRetention(t *testing.T) {
insertTime := time.Now() insertTime := time.Now()
fnTime := func(t1 time.Duration) float64 { _ = store.Put(createIndex([]byte{1}, float64(insertTime.Add(-70*time.Second).Unix())), "test", tests.CreateWakuMessage("test", 1))
return utils.GetUnixEpochFrom(func() time.Time { _ = store.Put(createIndex([]byte{2}, float64(insertTime.Add(-60*time.Second).Unix())), "test", tests.CreateWakuMessage("test", 2))
return insertTime.Add(t1) _ = store.Put(createIndex([]byte{3}, float64(insertTime.Add(-50*time.Second).Unix())), "test", tests.CreateWakuMessage("test", 3))
}) _ = store.Put(createIndex([]byte{4}, float64(insertTime.Add(-40*time.Second).Unix())), "test", tests.CreateWakuMessage("test", 4))
} _ = store.Put(createIndex([]byte{5}, float64(insertTime.Add(-30*time.Second).Unix())), "test", tests.CreateWakuMessage("test", 5))
_ = store.Put(createIndex([]byte{1}, fnTime(-70*time.Second)), "test", tests.CreateWakuMessage("test", 1))
_ = store.Put(createIndex([]byte{2}, fnTime(-60*time.Second)), "test", tests.CreateWakuMessage("test", 2))
_ = store.Put(createIndex([]byte{3}, fnTime(-50*time.Second)), "test", tests.CreateWakuMessage("test", 3))
_ = store.Put(createIndex([]byte{4}, fnTime(-40*time.Second)), "test", tests.CreateWakuMessage("test", 4))
_ = store.Put(createIndex([]byte{5}, fnTime(-30*time.Second)), "test", tests.CreateWakuMessage("test", 5))
dbResults, err := store.GetAll() dbResults, err := store.GetAll()
require.NoError(t, err) require.NoError(t, err)
require.Len(t, dbResults, 5) require.Len(t, dbResults, 5)
_ = store.Put(createIndex([]byte{6}, fnTime(-20*time.Second)), "test", tests.CreateWakuMessage("test", 6)) _ = store.Put(createIndex([]byte{6}, float64(insertTime.Add(-20*time.Second).Unix())), "test", tests.CreateWakuMessage("test", 6))
_ = store.Put(createIndex([]byte{7}, fnTime(-10*time.Second)), "test", tests.CreateWakuMessage("test", 7)) _ = store.Put(createIndex([]byte{7}, float64(insertTime.Add(-10*time.Second).Unix())), "test", tests.CreateWakuMessage("test", 7))
// This step simulates starting go-waku again from scratch // This step simulates starting go-waku again from scratch

View File

@ -145,7 +145,7 @@ func (store *WakuStore) FindMessages(query *pb.HistoryQuery) *pb.HistoryResponse
result := new(pb.HistoryResponse) result := new(pb.HistoryResponse)
// data holds IndexedWakuMessage whose topics match the query // data holds IndexedWakuMessage whose topics match the query
var data []IndexedWakuMessage var data []IndexedWakuMessage
for _, indexedMsg := range w.messageQueue.messages { for _, indexedMsg := range store.messageQueue.messages {
// temporal filtering // temporal filtering
// check whether the history query contains a time filter // check whether the history query contains a time filter
if query.StartTime != 0 && query.EndTime != 0 { if query.StartTime != 0 && query.EndTime != 0 {