From b3187abce1d8ccebc030259894acce856468f71b Mon Sep 17 00:00:00 2001 From: Samuel Hawksby-Robinson Date: Wed, 16 Dec 2020 18:28:34 +0000 Subject: [PATCH] Fix for int64 pointer bug --- protocol/messenger.go | 2 +- protocol/persistence.go | 8 ++++---- protocol/persistence_test.go | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/protocol/messenger.go b/protocol/messenger.go index 1e0630a2d..e5b3ea745 100644 --- a/protocol/messenger.go +++ b/protocol/messenger.go @@ -604,7 +604,7 @@ func (m *Messenger) shouldPublishChatIdentity(chatID string) (bool, error) { return true, nil } - return *lp == 0 || time.Now().Unix()-*lp > 24*60*60, nil + return lp == 0 || time.Now().Unix()-lp > 24*60*60, nil } // createChatIdentity creates a context based protobuf.ChatIdentity. diff --git a/protocol/persistence.go b/protocol/persistence.go index 42c2ac733..9cf8cc19e 100644 --- a/protocol/persistence.go +++ b/protocol/persistence.go @@ -856,19 +856,19 @@ func (db sqlitePersistence) TransactionsToValidate() ([]*TransactionToValidate, return transactions, nil } -func (db sqlitePersistence) GetWhenChatIdentityLastPublished(chatID string) (t *int64, hash []byte, err error) { +func (db sqlitePersistence) GetWhenChatIdentityLastPublished(chatID string) (t int64, hash []byte, err error) { rows, err := db.db.Query("SELECT clock_value, hash FROM chat_identity_last_published WHERE chat_id = ?", chatID) if err != nil { - return nil, nil, err + return t, nil, err } defer func() { err = rows.Close() }() for rows.Next() { - err = rows.Scan(t, &hash) + err = rows.Scan(&t, &hash) if err != nil { - return nil, nil, err + return t, nil, err } } diff --git a/protocol/persistence_test.go b/protocol/persistence_test.go index cd3bfbcca..47abd19f0 100644 --- a/protocol/persistence_test.go +++ b/protocol/persistence_test.go @@ -659,7 +659,7 @@ func TestSqlitePersistence_GetWhenChatIdentityLastPublished(t *testing.T) { require.NoError(t, err) // Check that the save happened in the last 2 seconds - diff := *ts - now + diff := ts - now require.LessOrEqual(t, diff, int64(2)) require.True(t, bytes.Equal(hash, actualHash)) @@ -667,7 +667,7 @@ func TestSqlitePersistence_GetWhenChatIdentityLastPublished(t *testing.T) { // Require unsaved values to be zero ts2, actualHash2, err := p.GetWhenChatIdentityLastPublished("0xdeadbeef") require.NoError(t, err) - require.Exactly(t, int64(0), *ts2) + require.Exactly(t, int64(0), ts2) require.Nil(t, actualHash2) }