From ed34afafa8e957ed8d9151cd52938baa6a77e0aa Mon Sep 17 00:00:00 2001 From: Pedro Pombeiro Date: Thu, 19 Dec 2019 16:40:44 +0100 Subject: [PATCH 1/2] Run `gofmt -s -w` --- eth-node/bridge/nimbus/node.go | 8 ++-- protocol/message_processor_test.go | 2 +- protocol/messenger.go | 4 +- protocol/messenger_test.go | 38 +++++++++---------- protocol/persistence_legacy_test.go | 2 +- .../status-im/status-go/protocol/messenger.go | 4 +- whisper/rate_limiter_test.go | 2 +- 7 files changed, 30 insertions(+), 30 deletions(-) diff --git a/eth-node/bridge/nimbus/node.go b/eth-node/bridge/nimbus/node.go index 1419fa6d611..3c2762cda5b 100644 --- a/eth-node/bridge/nimbus/node.go +++ b/eth-node/bridge/nimbus/node.go @@ -33,12 +33,12 @@ import ( type nimbusNodeWrapper struct { mu sync.Mutex - routineQueue *RoutineQueue - tid int + routineQueue *RoutineQueue + tid int nodeStarted bool cancelPollingChan chan struct{} - w types.Whisper + w types.Whisper } type Node interface { @@ -122,7 +122,7 @@ func (n *nimbusNodeWrapper) poll() { panic("poll called from wrong thread") } - if (n.nodeStarted) { + if n.nodeStarted { C.nimbus_poll() } diff --git a/protocol/message_processor_test.go b/protocol/message_processor_test.go index 098280cdf85..d0a258edd9c 100644 --- a/protocol/message_processor_test.go +++ b/protocol/message_processor_test.go @@ -190,7 +190,7 @@ func (s *MessageProcessorSuite) TestHandleDecodedMessagesDatasyncEncrypted() { dataSyncMessage := datasyncproto.Payload{ Messages: []*datasyncproto.Message{ - &datasyncproto.Message{Body: wrappedPayload}, + {Body: wrappedPayload}, }, } marshalledDataSyncMessage, err := proto.Marshal(&dataSyncMessage) diff --git a/protocol/messenger.go b/protocol/messenger.go index b0cf326d50a..42014446818 100644 --- a/protocol/messenger.go +++ b/protocol/messenger.go @@ -1468,11 +1468,11 @@ func (m *Messenger) handleRetrievedMessages(chatWithMessages map[transport.Filte } } - for id, _ := range modifiedChats { + for id := range modifiedChats { response.Chats = append(response.Chats, m.allChats[id]) } - for id, _ := range modifiedContacts { + for id := range modifiedContacts { response.Contacts = append(response.Contacts, m.allContacts[id]) } diff --git a/protocol/messenger_test.go b/protocol/messenger_test.go index d5136e5062b..d657a8cddb0 100644 --- a/protocol/messenger_test.go +++ b/protocol/messenger_test.go @@ -1097,17 +1097,17 @@ func (s *MessengerSuite) TestChatPersistencePrivateGroupChat() { ChatType: ChatTypePrivateGroupChat, Timestamp: 10, Members: []ChatMember{ - ChatMember{ + { ID: "1", Admin: false, Joined: true, }, - ChatMember{ + { ID: "2", Admin: true, Joined: false, }, - ChatMember{ + { ID: "3", Admin: true, Joined: true, @@ -1157,12 +1157,12 @@ func (s *MessengerSuite) TestBlockContact() { LastUpdated: 20, SystemTags: []string{"1", "2"}, DeviceInfo: []ContactDeviceInfo{ - ContactDeviceInfo{ + { InstallationID: "1", Timestamp: 2, FCMToken: "token", }, - ContactDeviceInfo{ + { InstallationID: "2", Timestamp: 3, FCMToken: "token-2", @@ -1216,7 +1216,7 @@ func (s *MessengerSuite) TestBlockContact() { contact.Name = "blocked" messages := []*Message{ - &Message{ + { ID: "test-1", LocalChatID: chat2.ID, ChatMessage: protobuf.ChatMessage{ @@ -1226,7 +1226,7 @@ func (s *MessengerSuite) TestBlockContact() { }, From: contact.ID, }, - &Message{ + { ID: "test-2", LocalChatID: chat2.ID, ChatMessage: protobuf.ChatMessage{ @@ -1236,7 +1236,7 @@ func (s *MessengerSuite) TestBlockContact() { }, From: contact.ID, }, - &Message{ + { ID: "test-3", LocalChatID: chat2.ID, ChatMessage: protobuf.ChatMessage{ @@ -1247,7 +1247,7 @@ func (s *MessengerSuite) TestBlockContact() { Seen: false, From: "test", }, - &Message{ + { ID: "test-4", LocalChatID: chat2.ID, ChatMessage: protobuf.ChatMessage{ @@ -1258,7 +1258,7 @@ func (s *MessengerSuite) TestBlockContact() { Seen: false, From: "test", }, - &Message{ + { ID: "test-5", LocalChatID: chat2.ID, ChatMessage: protobuf.ChatMessage{ @@ -1269,7 +1269,7 @@ func (s *MessengerSuite) TestBlockContact() { Seen: true, From: "test", }, - &Message{ + { ID: "test-6", LocalChatID: chat3.ID, ChatMessage: protobuf.ChatMessage{ @@ -1280,7 +1280,7 @@ func (s *MessengerSuite) TestBlockContact() { Seen: false, From: contact.ID, }, - &Message{ + { ID: "test-7", LocalChatID: chat3.ID, ChatMessage: protobuf.ChatMessage{ @@ -1346,12 +1346,12 @@ func (s *MessengerSuite) TestContactPersistence() { LastUpdated: 20, SystemTags: []string{"1", "2"}, DeviceInfo: []ContactDeviceInfo{ - ContactDeviceInfo{ + { InstallationID: "1", Timestamp: 2, FCMToken: "token", }, - ContactDeviceInfo{ + { InstallationID: "2", Timestamp: 3, FCMToken: "token-2", @@ -1388,17 +1388,17 @@ func (s *MessengerSuite) TestVerifyENSNames() { PublicKeyString: pk1, }, // Not matching pk -> name - enstypes.ENSDetails{ + { Name: "pedro.stateofus.eth", PublicKeyString: pk2, }, // Not existing name - enstypes.ENSDetails{ + { Name: "definitelynotpedro.stateofus.eth", PublicKeyString: pk3, }, // Malformed pk - enstypes.ENSDetails{ + { Name: "pedro.stateofus.eth", PublicKeyString: pk4, }, @@ -1454,12 +1454,12 @@ func (s *MessengerSuite) TestContactPersistenceUpdate() { LastUpdated: 20, SystemTags: []string{"1", "2"}, DeviceInfo: []ContactDeviceInfo{ - ContactDeviceInfo{ + { InstallationID: "1", Timestamp: 2, FCMToken: "token", }, - ContactDeviceInfo{ + { InstallationID: "2", Timestamp: 3, FCMToken: "token-2", diff --git a/protocol/persistence_legacy_test.go b/protocol/persistence_legacy_test.go index 62765043f13..30cdff1a24c 100644 --- a/protocol/persistence_legacy_test.go +++ b/protocol/persistence_legacy_test.go @@ -364,7 +364,7 @@ func openTestDB() (*sql.DB, error) { } func insertMinimalMessage(p sqlitePersistence, id string) error { - return p.SaveMessagesLegacy([]*Message{&Message{ + return p.SaveMessagesLegacy([]*Message{{ ID: id, LocalChatID: "chat-id", ChatMessage: protobuf.ChatMessage{Text: "some-text"}, diff --git a/vendor/github.com/status-im/status-go/protocol/messenger.go b/vendor/github.com/status-im/status-go/protocol/messenger.go index b0cf326d50a..42014446818 100644 --- a/vendor/github.com/status-im/status-go/protocol/messenger.go +++ b/vendor/github.com/status-im/status-go/protocol/messenger.go @@ -1468,11 +1468,11 @@ func (m *Messenger) handleRetrievedMessages(chatWithMessages map[transport.Filte } } - for id, _ := range modifiedChats { + for id := range modifiedChats { response.Chats = append(response.Chats, m.allChats[id]) } - for id, _ := range modifiedContacts { + for id := range modifiedContacts { response.Contacts = append(response.Contacts, m.allContacts[id]) } diff --git a/whisper/rate_limiter_test.go b/whisper/rate_limiter_test.go index 4ca63920b36..b083894a9b4 100644 --- a/whisper/rate_limiter_test.go +++ b/whisper/rate_limiter_test.go @@ -99,7 +99,7 @@ func TestPeerLimiterHandlerWithWhitelisting(t *testing.T) { LimitPerSecIP: 1, LimitPerSecPeerID: 1, WhitelistedIPs: []string{""}, // no IP is represented as string - WhitelistedPeerIDs: []enode.ID{enode.ID{0xaa, 0xbb, 0xcc}}, + WhitelistedPeerIDs: []enode.ID{{0xaa, 0xbb, 0xcc}}, }, h) p := &Peer{ peer: p2p.NewPeer(enode.ID{0xaa, 0xbb, 0xcc}, "test-peer", nil), From 4bee86b7e8daff9c999a2ed8828915f3f58583a9 Mon Sep 17 00:00:00 2001 From: Pedro Pombeiro Date: Thu, 19 Dec 2019 17:03:00 +0100 Subject: [PATCH 2/2] Migrate more files to eth-node/crypto --- account/address.go | 2 +- account/generator/account.go | 2 +- account/generator/utils.go | 2 +- account/onboarding.go | 2 +- api/utils.go | 2 +- lib/library_test_multiaccount.go | 2 +- params/config.go | 10 +++++----- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/account/address.go b/account/address.go index 377f45a965f..f30d6fe6cc5 100644 --- a/account/address.go +++ b/account/address.go @@ -1,7 +1,7 @@ package account import ( - "github.com/ethereum/go-ethereum/crypto" + "github.com/status-im/status-go/eth-node/crypto" "github.com/status-im/status-go/eth-node/types" ) diff --git a/account/generator/account.go b/account/generator/account.go index 9329bce8c3a..bdc4cb3f1d7 100644 --- a/account/generator/account.go +++ b/account/generator/account.go @@ -4,7 +4,7 @@ import ( "crypto/ecdsa" "crypto/sha256" - "github.com/ethereum/go-ethereum/crypto" + "github.com/status-im/status-go/eth-node/crypto" "github.com/status-im/status-go/eth-node/types" "github.com/status-im/status-go/extkeys" ) diff --git a/account/generator/utils.go b/account/generator/utils.go index aa9cf2b4ed5..818c0103a68 100644 --- a/account/generator/utils.go +++ b/account/generator/utils.go @@ -5,7 +5,7 @@ import ( "errors" "github.com/ethereum/go-ethereum/accounts/keystore" - "github.com/ethereum/go-ethereum/crypto" + "github.com/status-im/status-go/eth-node/crypto" "github.com/status-im/status-go/extkeys" ) diff --git a/account/onboarding.go b/account/onboarding.go index 5ea4c85d002..f2fb2f45897 100644 --- a/account/onboarding.go +++ b/account/onboarding.go @@ -3,9 +3,9 @@ package account import ( "fmt" - "github.com/ethereum/go-ethereum/crypto" "github.com/pborman/uuid" "github.com/status-im/status-go/account/generator" + "github.com/status-im/status-go/eth-node/crypto" "github.com/status-im/status-go/eth-node/types" "github.com/status-im/status-go/extkeys" ) diff --git a/api/utils.go b/api/utils.go index 812c04adb0c..f15e28db8f0 100644 --- a/api/utils.go +++ b/api/utils.go @@ -6,7 +6,7 @@ import ( "strconv" "strings" - "github.com/ethereum/go-ethereum/crypto" + "github.com/status-im/status-go/eth-node/crypto" ) // RunAsync runs the specified function asynchronously. diff --git a/lib/library_test_multiaccount.go b/lib/library_test_multiaccount.go index 9b5b693f1c4..b683256fb01 100644 --- a/lib/library_test_multiaccount.go +++ b/lib/library_test_multiaccount.go @@ -6,7 +6,7 @@ import ( "C" "encoding/json" - "github.com/ethereum/go-ethereum/crypto" + "github.com/status-im/status-go/eth-node/crypto" mobile "github.com/status-im/status-go/mobile" ) import ( diff --git a/params/config.go b/params/config.go index 4b0be67b407..e616c4d5663 100644 --- a/params/config.go +++ b/params/config.go @@ -11,11 +11,11 @@ import ( "strings" "time" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/p2p/discv5" "github.com/ethereum/go-ethereum/params" + "github.com/status-im/status-go/eth-node/crypto" + "github.com/status-im/status-go/eth-node/types" "github.com/status-im/status-go/static" "github.com/status-im/status-go/whisper/v6" validator "gopkg.in/go-playground/validator.v9" @@ -890,11 +890,11 @@ func (c *NodeConfig) AddAPIModule(m string) { func LesTopic(netid int) string { switch netid { case 1: - return LESDiscoveryIdentifier + common.Bytes2Hex(params.MainnetGenesisHash.Bytes()[:8]) + return LESDiscoveryIdentifier + types.Bytes2Hex(params.MainnetGenesisHash.Bytes()[:8]) case 3: - return LESDiscoveryIdentifier + common.Bytes2Hex(params.TestnetGenesisHash.Bytes()[:8]) + return LESDiscoveryIdentifier + types.Bytes2Hex(params.TestnetGenesisHash.Bytes()[:8]) case 4: - return LESDiscoveryIdentifier + common.Bytes2Hex(params.RinkebyGenesisHash.Bytes()[:8]) + return LESDiscoveryIdentifier + types.Bytes2Hex(params.RinkebyGenesisHash.Bytes()[:8]) default: return "" }