Fix modvendor (#1690)

This commit is contained in:
Adam Babik 2019-11-22 13:24:20 +01:00 committed by GitHub
parent ed5a5c154d
commit e1a8ba1ba5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 127 additions and 123 deletions

3
.gitignore vendored
View File

@ -69,3 +69,6 @@ Session.vim
# created for running container # created for running container
_assets/compose/bootnode/keys _assets/compose/bootnode/keys
# do not vendor nested vendor dirs
vendor/**/vendor

View File

@ -216,7 +216,8 @@ xtools-install:
modvendor-install: modvendor-install:
# a tool to vendor non-go files # a tool to vendor non-go files
go get -u github.com/goware/modvendor # TODO: switch to original repo when https://github.com/goware/modvendor/pull/13 is merged
GO111MODULE=off go get -u github.com/adambabik/modvendor
mock-install: ##@other Install mocking tools mock-install: ##@other Install mocking tools
go get -u github.com/golang/mock/mockgen go get -u github.com/golang/mock/mockgen

View File

@ -2,7 +2,7 @@ package gethbridge
import ( import (
whispertypes "github.com/status-im/status-go/protocol/transport/whisper/types" whispertypes "github.com/status-im/status-go/protocol/transport/whisper/types"
statusproto "github.com/status-im/status-go/protocol/types" protocol "github.com/status-im/status-go/protocol/types"
whisper "github.com/status-im/whisper/whisperv6" whisper "github.com/status-im/whisper/whisperv6"
) )
@ -22,8 +22,8 @@ func GetGethEnvelopeFrom(f whispertypes.Envelope) *whisper.Envelope {
return f.(*gethEnvelopeWrapper).envelope return f.(*gethEnvelopeWrapper).envelope
} }
func (w *gethEnvelopeWrapper) Hash() statusproto.Hash { func (w *gethEnvelopeWrapper) Hash() protocol.Hash {
return statusproto.Hash(w.envelope.Hash()) return protocol.Hash(w.envelope.Hash())
} }
func (w *gethEnvelopeWrapper) Bloom() []byte { func (w *gethEnvelopeWrapper) Bloom() []byte {

View File

@ -2,7 +2,7 @@ package gethbridge
import ( import (
whispertypes "github.com/status-im/status-go/protocol/transport/whisper/types" whispertypes "github.com/status-im/status-go/protocol/transport/whisper/types"
statusproto "github.com/status-im/status-go/protocol/types" protocol "github.com/status-im/status-go/protocol/types"
whisper "github.com/status-im/whisper/whisperv6" whisper "github.com/status-im/whisper/whisperv6"
) )
@ -13,7 +13,7 @@ func NewGethEnvelopeErrorWrapper(envelopeError *whisper.EnvelopeError) *whispert
} }
return &whispertypes.EnvelopeError{ return &whispertypes.EnvelopeError{
Hash: statusproto.Hash(envelopeError.Hash), Hash: protocol.Hash(envelopeError.Hash),
Code: mapGethErrorCode(envelopeError.Code), Code: mapGethErrorCode(envelopeError.Code),
Description: envelopeError.Description, Description: envelopeError.Description,
} }

View File

@ -2,7 +2,7 @@ package gethbridge
import ( import (
whispertypes "github.com/status-im/status-go/protocol/transport/whisper/types" whispertypes "github.com/status-im/status-go/protocol/transport/whisper/types"
statusproto "github.com/status-im/status-go/protocol/types" protocol "github.com/status-im/status-go/protocol/types"
whisper "github.com/status-im/whisper/whisperv6" whisper "github.com/status-im/whisper/whisperv6"
) )
@ -26,8 +26,8 @@ func NewGethEnvelopeEventWrapper(envelopeEvent *whisper.EnvelopeEvent) *whispert
} }
return &whispertypes.EnvelopeEvent{ return &whispertypes.EnvelopeEvent{
Event: whispertypes.EventType(envelopeEvent.Event), Event: whispertypes.EventType(envelopeEvent.Event),
Hash: statusproto.Hash(envelopeEvent.Hash), Hash: protocol.Hash(envelopeEvent.Hash),
Batch: statusproto.Hash(envelopeEvent.Batch), Batch: protocol.Hash(envelopeEvent.Batch),
Peer: whispertypes.EnodeID(envelopeEvent.Peer), Peer: whispertypes.EnodeID(envelopeEvent.Peer),
Data: wrappedData, Data: wrappedData,
} }

View File

@ -2,7 +2,7 @@ package gethbridge
import ( import (
whispertypes "github.com/status-im/status-go/protocol/transport/whisper/types" whispertypes "github.com/status-im/status-go/protocol/transport/whisper/types"
statusproto "github.com/status-im/status-go/protocol/types" protocol "github.com/status-im/status-go/protocol/types"
whisper "github.com/status-im/whisper/whisperv6" whisper "github.com/status-im/whisper/whisperv6"
) )
@ -13,7 +13,7 @@ func NewGethMailServerResponseWrapper(mailServerResponse *whisper.MailServerResp
} }
return &whispertypes.MailServerResponse{ return &whispertypes.MailServerResponse{
LastEnvelopeHash: statusproto.Hash(mailServerResponse.LastEnvelopeHash), LastEnvelopeHash: protocol.Hash(mailServerResponse.LastEnvelopeHash),
Cursor: mailServerResponse.Cursor, Cursor: mailServerResponse.Cursor,
Error: mailServerResponse.Error, Error: mailServerResponse.Error,
} }

View File

@ -5,7 +5,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/hexutil"
whispertypes "github.com/status-im/status-go/protocol/transport/whisper/types" whispertypes "github.com/status-im/status-go/protocol/transport/whisper/types"
statusproto "github.com/status-im/status-go/protocol/types" protocol "github.com/status-im/status-go/protocol/types"
whisper "github.com/status-im/whisper/whisperv6" whisper "github.com/status-im/whisper/whisperv6"
) )
@ -25,7 +25,7 @@ func NewGethPublicWhisperAPIWrapper(publicWhisperAPI *whisper.PublicWhisperAPI)
} }
// AddPrivateKey imports the given private key. // AddPrivateKey imports the given private key.
func (w *gethPublicWhisperAPIWrapper) AddPrivateKey(ctx context.Context, privateKey statusproto.HexBytes) (string, error) { func (w *gethPublicWhisperAPIWrapper) AddPrivateKey(ctx context.Context, privateKey protocol.HexBytes) (string, error) {
return w.publicWhisperAPI.AddPrivateKey(ctx, hexutil.Bytes(privateKey)) return w.publicWhisperAPI.AddPrivateKey(ctx, hexutil.Bytes(privateKey))
} }

View File

@ -6,7 +6,7 @@ import (
"encoding/hex" "encoding/hex"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
statusproto "github.com/status-im/status-go/protocol/types" protocol "github.com/status-im/status-go/protocol/types"
v1protocol "github.com/status-im/status-go/protocol/v1" v1protocol "github.com/status-im/status-go/protocol/v1"
) )
@ -140,7 +140,7 @@ type ChatMember struct {
} }
func (c ChatMember) PublicKey() (*ecdsa.PublicKey, error) { func (c ChatMember) PublicKey() (*ecdsa.PublicKey, error) {
b, err := statusproto.DecodeHex(c.ID) b, err := protocol.DecodeHex(c.ID)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -148,7 +148,7 @@ func (c ChatMember) PublicKey() (*ecdsa.PublicKey, error) {
} }
func oneToOneChatID(publicKey *ecdsa.PublicKey) string { func oneToOneChatID(publicKey *ecdsa.PublicKey) string {
return statusproto.EncodeHex(crypto.FromECDSAPub(publicKey)) return protocol.EncodeHex(crypto.FromECDSAPub(publicKey))
} }
func CreateOneToOneChat(name string, publicKey *ecdsa.PublicKey) Chat { func CreateOneToOneChat(name string, publicKey *ecdsa.PublicKey) Chat {
@ -194,7 +194,7 @@ func stringSliceToPublicKeys(slice []string, prefixed bool) ([]*ecdsa.PublicKey,
err error err error
) )
if prefixed { if prefixed {
b, err = statusproto.DecodeHex(item) b, err = protocol.DecodeHex(item)
} else { } else {
b, err = hex.DecodeString(item) b, err = hex.DecodeString(item)
} }

View File

@ -8,7 +8,7 @@ import (
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/status-im/status-go/protocol/identity/alias" "github.com/status-im/status-go/protocol/identity/alias"
"github.com/status-im/status-go/protocol/identity/identicon" "github.com/status-im/status-go/protocol/identity/identicon"
statusproto "github.com/status-im/status-go/protocol/types" protocol "github.com/status-im/status-go/protocol/types"
) )
const ( const (
@ -58,7 +58,7 @@ type Contact struct {
} }
func (c Contact) PublicKey() (*ecdsa.PublicKey, error) { func (c Contact) PublicKey() (*ecdsa.PublicKey, error) {
b, err := statusproto.DecodeHex(c.ID) b, err := protocol.DecodeHex(c.ID)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -592,23 +592,23 @@ type bintree struct {
} }
var _bintree = &bintree{nil, map[string]*bintree{ var _bintree = &bintree{nil, map[string]*bintree{
"1536754952_initial_schema.down.sql": &bintree{_1536754952_initial_schemaDownSql, map[string]*bintree{}}, "1536754952_initial_schema.down.sql": {_1536754952_initial_schemaDownSql, map[string]*bintree{}},
"1536754952_initial_schema.up.sql": &bintree{_1536754952_initial_schemaUpSql, map[string]*bintree{}}, "1536754952_initial_schema.up.sql": {_1536754952_initial_schemaUpSql, map[string]*bintree{}},
"1539249977_update_ratchet_info.down.sql": &bintree{_1539249977_update_ratchet_infoDownSql, map[string]*bintree{}}, "1539249977_update_ratchet_info.down.sql": {_1539249977_update_ratchet_infoDownSql, map[string]*bintree{}},
"1539249977_update_ratchet_info.up.sql": &bintree{_1539249977_update_ratchet_infoUpSql, map[string]*bintree{}}, "1539249977_update_ratchet_info.up.sql": {_1539249977_update_ratchet_infoUpSql, map[string]*bintree{}},
"1540715431_add_version.down.sql": &bintree{_1540715431_add_versionDownSql, map[string]*bintree{}}, "1540715431_add_version.down.sql": {_1540715431_add_versionDownSql, map[string]*bintree{}},
"1540715431_add_version.up.sql": &bintree{_1540715431_add_versionUpSql, map[string]*bintree{}}, "1540715431_add_version.up.sql": {_1540715431_add_versionUpSql, map[string]*bintree{}},
"1541164797_add_installations.down.sql": &bintree{_1541164797_add_installationsDownSql, map[string]*bintree{}}, "1541164797_add_installations.down.sql": {_1541164797_add_installationsDownSql, map[string]*bintree{}},
"1541164797_add_installations.up.sql": &bintree{_1541164797_add_installationsUpSql, map[string]*bintree{}}, "1541164797_add_installations.up.sql": {_1541164797_add_installationsUpSql, map[string]*bintree{}},
"1558084410_add_secret.down.sql": &bintree{_1558084410_add_secretDownSql, map[string]*bintree{}}, "1558084410_add_secret.down.sql": {_1558084410_add_secretDownSql, map[string]*bintree{}},
"1558084410_add_secret.up.sql": &bintree{_1558084410_add_secretUpSql, map[string]*bintree{}}, "1558084410_add_secret.up.sql": {_1558084410_add_secretUpSql, map[string]*bintree{}},
"1558588866_add_version.down.sql": &bintree{_1558588866_add_versionDownSql, map[string]*bintree{}}, "1558588866_add_version.down.sql": {_1558588866_add_versionDownSql, map[string]*bintree{}},
"1558588866_add_version.up.sql": &bintree{_1558588866_add_versionUpSql, map[string]*bintree{}}, "1558588866_add_version.up.sql": {_1558588866_add_versionUpSql, map[string]*bintree{}},
"1559627659_add_contact_code.down.sql": &bintree{_1559627659_add_contact_codeDownSql, map[string]*bintree{}}, "1559627659_add_contact_code.down.sql": {_1559627659_add_contact_codeDownSql, map[string]*bintree{}},
"1559627659_add_contact_code.up.sql": &bintree{_1559627659_add_contact_codeUpSql, map[string]*bintree{}}, "1559627659_add_contact_code.up.sql": {_1559627659_add_contact_codeUpSql, map[string]*bintree{}},
"1561368210_add_installation_metadata.down.sql": &bintree{_1561368210_add_installation_metadataDownSql, map[string]*bintree{}}, "1561368210_add_installation_metadata.down.sql": {_1561368210_add_installation_metadataDownSql, map[string]*bintree{}},
"1561368210_add_installation_metadata.up.sql": &bintree{_1561368210_add_installation_metadataUpSql, map[string]*bintree{}}, "1561368210_add_installation_metadata.up.sql": {_1561368210_add_installation_metadataUpSql, map[string]*bintree{}},
"doc.go": &bintree{docGo, map[string]*bintree{}}, "doc.go": {docGo, map[string]*bintree{}},
}} }}
// RestoreAsset restores an asset under the given directory. // RestoreAsset restores an asset under the given directory.

View File

@ -4,17 +4,17 @@ import (
"database/sql/driver" "database/sql/driver"
"github.com/pkg/errors" "github.com/pkg/errors"
statusproto "github.com/status-im/status-go/protocol/types" protocol "github.com/status-im/status-go/protocol/types"
) )
type hexutilSQL statusproto.HexBytes type hexutilSQL protocol.HexBytes
func (h hexutilSQL) Value() (driver.Value, error) { func (h hexutilSQL) Value() (driver.Value, error) {
return []byte(h), nil return []byte(h), nil
} }
func (h hexutilSQL) String() string { func (h hexutilSQL) String() string {
return statusproto.EncodeHex(h) return protocol.EncodeHex(h)
} }
func (h *hexutilSQL) Scan(value interface{}) error { func (h *hexutilSQL) Scan(value interface{}) error {

View File

@ -20,7 +20,7 @@ import (
"github.com/status-im/status-go/protocol/sqlite" "github.com/status-im/status-go/protocol/sqlite"
transport "github.com/status-im/status-go/protocol/transport/whisper" transport "github.com/status-im/status-go/protocol/transport/whisper"
whispertypes "github.com/status-im/status-go/protocol/transport/whisper/types" whispertypes "github.com/status-im/status-go/protocol/transport/whisper/types"
statusproto "github.com/status-im/status-go/protocol/types" protocol "github.com/status-im/status-go/protocol/types"
v1protocol "github.com/status-im/status-go/protocol/v1" v1protocol "github.com/status-im/status-go/protocol/v1"
) )
@ -497,7 +497,7 @@ func (m *Messenger) AddMembersToChat(ctx context.Context, chat *Chat, members []
} }
encodedMembers := make([]string, len(members)) encodedMembers := make([]string, len(members))
for idx, member := range members { for idx, member := range members {
encodedMembers[idx] = statusproto.EncodeHex(crypto.FromECDSAPub(member)) encodedMembers[idx] = protocol.EncodeHex(crypto.FromECDSAPub(member))
} }
event := v1protocol.NewMembersAddedEvent(encodedMembers, group.NextClockValue()) event := v1protocol.NewMembersAddedEvent(encodedMembers, group.NextClockValue())
err = group.ProcessEvent(&m.identity.PublicKey, event) err = group.ProcessEvent(&m.identity.PublicKey, event)
@ -517,7 +517,7 @@ func (m *Messenger) ConfirmJoiningGroup(ctx context.Context, chat *Chat) error {
return err return err
} }
event := v1protocol.NewMemberJoinedEvent( event := v1protocol.NewMemberJoinedEvent(
statusproto.EncodeHex(crypto.FromECDSAPub(&m.identity.PublicKey)), protocol.EncodeHex(crypto.FromECDSAPub(&m.identity.PublicKey)),
group.NextClockValue(), group.NextClockValue(),
) )
err = group.ProcessEvent(&m.identity.PublicKey, event) err = group.ProcessEvent(&m.identity.PublicKey, event)
@ -1045,7 +1045,7 @@ func (p *postProcessor) matchMessage(message *v1protocol.Message, chats []*Chat)
case message.MessageT == v1protocol.MessageTypePrivate: case message.MessageT == v1protocol.MessageTypePrivate:
// It's an incoming private message. ChatID is calculated from the signature. // It's an incoming private message. ChatID is calculated from the signature.
// If a chat does not exist, a new one is created and saved. // If a chat does not exist, a new one is created and saved.
chatID := statusproto.EncodeHex(crypto.FromECDSAPub(message.SigPubKey)) chatID := protocol.EncodeHex(crypto.FromECDSAPub(message.SigPubKey))
chat := findChatByID(chatID, chats) chat := findChatByID(chatID, chats)
if chat == nil { if chat == nil {
// TODO: this should be a three-word name used in the mobile client // TODO: this should be a three-word name used in the mobile client
@ -1065,7 +1065,7 @@ func (p *postProcessor) matchMessage(message *v1protocol.Message, chats []*Chat)
return nil, errors.New("received group chat message for non-existing chat") return nil, errors.New("received group chat message for non-existing chat")
} }
sigPubKeyHex := statusproto.EncodeHex(crypto.FromECDSAPub(message.SigPubKey)) sigPubKeyHex := protocol.EncodeHex(crypto.FromECDSAPub(message.SigPubKey))
for _, member := range chat.Members { for _, member := range chat.Members {
if member.ID == sigPubKeyHex { if member.ID == sigPubKeyHex {
return chat, nil return chat, nil

View File

@ -454,17 +454,17 @@ type bintree struct {
} }
var _bintree = &bintree{nil, map[string]*bintree{ var _bintree = &bintree{nil, map[string]*bintree{
"000001_init.down.db.sql": &bintree{_000001_initDownDbSql, map[string]*bintree{}}, "000001_init.down.db.sql": {_000001_initDownDbSql, map[string]*bintree{}},
"000001_init.up.db.sql": &bintree{_000001_initUpDbSql, map[string]*bintree{}}, "000001_init.up.db.sql": {_000001_initUpDbSql, map[string]*bintree{}},
"000002_add_chats.down.db.sql": &bintree{_000002_add_chatsDownDbSql, map[string]*bintree{}}, "000002_add_chats.down.db.sql": {_000002_add_chatsDownDbSql, map[string]*bintree{}},
"000002_add_chats.up.db.sql": &bintree{_000002_add_chatsUpDbSql, map[string]*bintree{}}, "000002_add_chats.up.db.sql": {_000002_add_chatsUpDbSql, map[string]*bintree{}},
"000003_add_contacts.down.db.sql": &bintree{_000003_add_contactsDownDbSql, map[string]*bintree{}}, "000003_add_contacts.down.db.sql": {_000003_add_contactsDownDbSql, map[string]*bintree{}},
"000003_add_contacts.up.db.sql": &bintree{_000003_add_contactsUpDbSql, map[string]*bintree{}}, "000003_add_contacts.up.db.sql": {_000003_add_contactsUpDbSql, map[string]*bintree{}},
"000004_user_messages_compatibility.down.sql": &bintree{_000004_user_messages_compatibilityDownSql, map[string]*bintree{}}, "000004_user_messages_compatibility.down.sql": {_000004_user_messages_compatibilityDownSql, map[string]*bintree{}},
"000004_user_messages_compatibility.up.sql": &bintree{_000004_user_messages_compatibilityUpSql, map[string]*bintree{}}, "000004_user_messages_compatibility.up.sql": {_000004_user_messages_compatibilityUpSql, map[string]*bintree{}},
"1567112142_user_messages.down.sql": &bintree{_1567112142_user_messagesDownSql, map[string]*bintree{}}, "1567112142_user_messages.down.sql": {_1567112142_user_messagesDownSql, map[string]*bintree{}},
"1567112142_user_messages.up.sql": &bintree{_1567112142_user_messagesUpSql, map[string]*bintree{}}, "1567112142_user_messages.up.sql": {_1567112142_user_messagesUpSql, map[string]*bintree{}},
"doc.go": &bintree{docGo, map[string]*bintree{}}, "doc.go": {docGo, map[string]*bintree{}},
}} }}
// RestoreAsset restores an asset under the given directory. // RestoreAsset restores an asset under the given directory.

View File

@ -6,7 +6,7 @@ import (
"sync" "sync"
whispertypes "github.com/status-im/status-go/protocol/transport/whisper/types" whispertypes "github.com/status-im/status-go/protocol/transport/whisper/types"
statusproto "github.com/status-im/status-go/protocol/types" protocol "github.com/status-im/status-go/protocol/types"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -34,8 +34,8 @@ type EnvelopesMonitorConfig struct {
type EnvelopeEventsHandler interface { type EnvelopeEventsHandler interface {
EnvelopeSent([][]byte) EnvelopeSent([][]byte)
EnvelopeExpired([][]byte, error) EnvelopeExpired([][]byte, error)
MailServerRequestCompleted(statusproto.Hash, statusproto.Hash, []byte, error) MailServerRequestCompleted(protocol.Hash, protocol.Hash, []byte, error)
MailServerRequestExpired(statusproto.Hash) MailServerRequestExpired(protocol.Hash)
} }
// NewEnvelopesMonitor returns a pointer to an instance of the EnvelopesMonitor. // NewEnvelopesMonitor returns a pointer to an instance of the EnvelopesMonitor.
@ -61,13 +61,13 @@ func NewEnvelopesMonitor(w whispertypes.Whisper, config EnvelopesMonitorConfig)
logger: logger.With(zap.Namespace("EnvelopesMonitor")), logger: logger.With(zap.Namespace("EnvelopesMonitor")),
// key is envelope hash (event.Hash) // key is envelope hash (event.Hash)
envelopes: map[statusproto.Hash]EnvelopeState{}, envelopes: map[protocol.Hash]EnvelopeState{},
messages: map[statusproto.Hash]*whispertypes.NewMessage{}, messages: map[protocol.Hash]*whispertypes.NewMessage{},
attempts: map[statusproto.Hash]int{}, attempts: map[protocol.Hash]int{},
identifiers: make(map[statusproto.Hash][][]byte), identifiers: make(map[protocol.Hash][][]byte),
// key is hash of the batch (event.Batch) // key is hash of the batch (event.Batch)
batches: map[statusproto.Hash]map[statusproto.Hash]struct{}{}, batches: map[protocol.Hash]map[protocol.Hash]struct{}{},
} }
} }
@ -80,12 +80,12 @@ type EnvelopesMonitor struct {
maxAttempts int maxAttempts int
mu sync.Mutex mu sync.Mutex
envelopes map[statusproto.Hash]EnvelopeState envelopes map[protocol.Hash]EnvelopeState
batches map[statusproto.Hash]map[statusproto.Hash]struct{} batches map[protocol.Hash]map[protocol.Hash]struct{}
messages map[statusproto.Hash]*whispertypes.NewMessage messages map[protocol.Hash]*whispertypes.NewMessage
attempts map[statusproto.Hash]int attempts map[protocol.Hash]int
identifiers map[statusproto.Hash][][]byte identifiers map[protocol.Hash][][]byte
wg sync.WaitGroup wg sync.WaitGroup
quit chan struct{} quit chan struct{}
@ -111,7 +111,7 @@ func (m *EnvelopesMonitor) Stop() {
} }
// Add hash to a tracker. // Add hash to a tracker.
func (m *EnvelopesMonitor) Add(identifiers [][]byte, envelopeHash statusproto.Hash, message whispertypes.NewMessage) { func (m *EnvelopesMonitor) Add(identifiers [][]byte, envelopeHash protocol.Hash, message whispertypes.NewMessage) {
m.mu.Lock() m.mu.Lock()
defer m.mu.Unlock() defer m.mu.Unlock()
m.envelopes[envelopeHash] = EnvelopePosted m.envelopes[envelopeHash] = EnvelopePosted
@ -120,7 +120,7 @@ func (m *EnvelopesMonitor) Add(identifiers [][]byte, envelopeHash statusproto.Ha
m.attempts[envelopeHash] = 1 m.attempts[envelopeHash] = 1
} }
func (m *EnvelopesMonitor) GetState(hash statusproto.Hash) EnvelopeState { func (m *EnvelopesMonitor) GetState(hash protocol.Hash) EnvelopeState {
m.mu.Lock() m.mu.Lock()
defer m.mu.Unlock() defer m.mu.Unlock()
state, exist := m.envelopes[hash] state, exist := m.envelopes[hash]
@ -179,9 +179,9 @@ func (m *EnvelopesMonitor) handleEventEnvelopeSent(event whispertypes.EnvelopeEv
return return
} }
m.logger.Debug("envelope is sent", zap.String("hash", event.Hash.String()), zap.String("peer", event.Peer.String())) m.logger.Debug("envelope is sent", zap.String("hash", event.Hash.String()), zap.String("peer", event.Peer.String()))
if event.Batch != (statusproto.Hash{}) { if event.Batch != (protocol.Hash{}) {
if _, ok := m.batches[event.Batch]; !ok { if _, ok := m.batches[event.Batch]; !ok {
m.batches[event.Batch] = map[statusproto.Hash]struct{}{} m.batches[event.Batch] = map[protocol.Hash]struct{}{}
} }
m.batches[event.Batch][event.Hash] = struct{}{} m.batches[event.Batch][event.Hash] = struct{}{}
m.logger.Debug("waiting for a confirmation", zap.String("batch", event.Batch.String())) m.logger.Debug("waiting for a confirmation", zap.String("batch", event.Batch.String()))
@ -212,7 +212,7 @@ func (m *EnvelopesMonitor) handleAcknowledgedBatch(event whispertypes.EnvelopeEv
if event.Data != nil && !ok { if event.Data != nil && !ok {
m.logger.Error("received unexpected data in the the confirmation event", zap.String("batch", event.Batch.String())) m.logger.Error("received unexpected data in the the confirmation event", zap.String("batch", event.Batch.String()))
} }
failedEnvelopes := map[statusproto.Hash]struct{}{} failedEnvelopes := map[protocol.Hash]struct{}{}
for i := range envelopeErrors { for i := range envelopeErrors {
envelopeError := envelopeErrors[i] envelopeError := envelopeErrors[i]
_, exist := m.envelopes[envelopeError.Hash] _, exist := m.envelopes[envelopeError.Hash]
@ -252,7 +252,7 @@ func (m *EnvelopesMonitor) handleEventEnvelopeExpired(event whispertypes.Envelop
// handleEnvelopeFailure is a common code path for processing envelopes failures. not thread safe, lock // handleEnvelopeFailure is a common code path for processing envelopes failures. not thread safe, lock
// must be used on a higher level. // must be used on a higher level.
func (m *EnvelopesMonitor) handleEnvelopeFailure(hash statusproto.Hash, err error) { func (m *EnvelopesMonitor) handleEnvelopeFailure(hash protocol.Hash, err error) {
if state, ok := m.envelopes[hash]; ok { if state, ok := m.envelopes[hash]; ok {
message, exist := m.messages[hash] message, exist := m.messages[hash]
if !exist { if !exist {
@ -274,7 +274,7 @@ func (m *EnvelopesMonitor) handleEnvelopeFailure(hash statusproto.Hash, err erro
} }
} }
envelopeID := statusproto.BytesToHash(hex) envelopeID := protocol.BytesToHash(hex)
m.envelopes[envelopeID] = EnvelopePosted m.envelopes[envelopeID] = EnvelopePosted
m.messages[envelopeID] = message m.messages[envelopeID] = message
m.attempts[envelopeID] = attempt + 1 m.attempts[envelopeID] = attempt + 1
@ -309,7 +309,7 @@ func (m *EnvelopesMonitor) handleEventEnvelopeReceived(event whispertypes.Envelo
// clearMessageState removes all message and envelope state. // clearMessageState removes all message and envelope state.
// not thread-safe, should be protected on a higher level. // not thread-safe, should be protected on a higher level.
func (m *EnvelopesMonitor) clearMessageState(envelopeID statusproto.Hash) { func (m *EnvelopesMonitor) clearMessageState(envelopeID protocol.Hash) {
delete(m.envelopes, envelopeID) delete(m.envelopes, envelopeID)
delete(m.messages, envelopeID) delete(m.messages, envelopeID)
delete(m.attempts, envelopeID) delete(m.attempts, envelopeID)

View File

@ -270,9 +270,9 @@ type bintree struct {
} }
var _bintree = &bintree{nil, map[string]*bintree{ var _bintree = &bintree{nil, map[string]*bintree{
"1561059285_add_whisper_keys.down.sql": &bintree{_1561059285_add_whisper_keysDownSql, map[string]*bintree{}}, "1561059285_add_whisper_keys.down.sql": {_1561059285_add_whisper_keysDownSql, map[string]*bintree{}},
"1561059285_add_whisper_keys.up.sql": &bintree{_1561059285_add_whisper_keysUpSql, map[string]*bintree{}}, "1561059285_add_whisper_keys.up.sql": {_1561059285_add_whisper_keysUpSql, map[string]*bintree{}},
"doc.go": &bintree{docGo, map[string]*bintree{}}, "doc.go": {docGo, map[string]*bintree{}},
}} }}
// RestoreAsset restores an asset under the given directory. // RestoreAsset restores an asset under the given directory.

View File

@ -1,11 +1,11 @@
package whispertypes package whispertypes
import statusproto "github.com/status-im/status-go/protocol/types" import protocol "github.com/status-im/status-go/protocol/types"
// Envelope represents a clear-text data packet to transmit through the Whisper // Envelope represents a clear-text data packet to transmit through the Whisper
// network. Its contents may or may not be encrypted and signed. // network. Its contents may or may not be encrypted and signed.
type Envelope interface { type Envelope interface {
Hash() statusproto.Hash // Cached hash of the envelope to avoid rehashing every time. Hash() protocol.Hash // Cached hash of the envelope to avoid rehashing every time.
Bloom() []byte Bloom() []byte
} }
@ -50,15 +50,15 @@ const (
// EnvelopeEvent used for envelopes events. // EnvelopeEvent used for envelopes events.
type EnvelopeEvent struct { type EnvelopeEvent struct {
Event EventType Event EventType
Hash statusproto.Hash Hash protocol.Hash
Batch statusproto.Hash Batch protocol.Hash
Peer EnodeID Peer EnodeID
Data interface{} Data interface{}
} }
// EnvelopeError code and optional description of the error. // EnvelopeError code and optional description of the error.
type EnvelopeError struct { type EnvelopeError struct {
Hash statusproto.Hash Hash protocol.Hash
Code uint Code uint
Description string Description string
} }

View File

@ -5,21 +5,21 @@ package whispertypes
import ( import (
"encoding/json" "encoding/json"
statusproto "github.com/status-im/status-go/protocol/types" protocol "github.com/status-im/status-go/protocol/types"
) )
// MarshalJSON marshals type Message to a json string // MarshalJSON marshals type Message to a json string
func (m Message) MarshalJSON() ([]byte, error) { func (m Message) MarshalJSON() ([]byte, error) {
type Message struct { type Message struct {
Sig statusproto.HexBytes `json:"sig,omitempty"` Sig protocol.HexBytes `json:"sig,omitempty"`
TTL uint32 `json:"ttl"` TTL uint32 `json:"ttl"`
Timestamp uint32 `json:"timestamp"` Timestamp uint32 `json:"timestamp"`
Topic TopicType `json:"topic"` Topic TopicType `json:"topic"`
Payload statusproto.HexBytes `json:"payload"` Payload protocol.HexBytes `json:"payload"`
Padding statusproto.HexBytes `json:"padding"` Padding protocol.HexBytes `json:"padding"`
PoW float64 `json:"pow"` PoW float64 `json:"pow"`
Hash statusproto.HexBytes `json:"hash"` Hash protocol.HexBytes `json:"hash"`
Dst statusproto.HexBytes `json:"recipientPublicKey,omitempty"` Dst protocol.HexBytes `json:"recipientPublicKey,omitempty"`
} }
var enc Message var enc Message
enc.Sig = m.Sig enc.Sig = m.Sig
@ -37,15 +37,15 @@ func (m Message) MarshalJSON() ([]byte, error) {
// UnmarshalJSON unmarshals type Message to a json string // UnmarshalJSON unmarshals type Message to a json string
func (m *Message) UnmarshalJSON(input []byte) error { func (m *Message) UnmarshalJSON(input []byte) error {
type Message struct { type Message struct {
Sig *statusproto.HexBytes `json:"sig,omitempty"` Sig *protocol.HexBytes `json:"sig,omitempty"`
TTL *uint32 `json:"ttl"` TTL *uint32 `json:"ttl"`
Timestamp *uint32 `json:"timestamp"` Timestamp *uint32 `json:"timestamp"`
Topic *TopicType `json:"topic"` Topic *TopicType `json:"topic"`
Payload *statusproto.HexBytes `json:"payload"` Payload *protocol.HexBytes `json:"payload"`
Padding *statusproto.HexBytes `json:"padding"` Padding *protocol.HexBytes `json:"padding"`
PoW *float64 `json:"pow"` PoW *float64 `json:"pow"`
Hash *statusproto.HexBytes `json:"hash"` Hash *protocol.HexBytes `json:"hash"`
Dst *statusproto.HexBytes `json:"recipientPublicKey,omitempty"` Dst *protocol.HexBytes `json:"recipientPublicKey,omitempty"`
} }
var dec Message var dec Message
if err := json.Unmarshal(input, &dec); err != nil { if err := json.Unmarshal(input, &dec); err != nil {

View File

@ -3,7 +3,7 @@ package whispertypes
import ( import (
"time" "time"
statusproto "github.com/status-im/status-go/protocol/types" protocol "github.com/status-im/status-go/protocol/types"
) )
const ( const (
@ -49,7 +49,7 @@ func (r *MessagesRequest) SetDefaults(now time.Time) {
// MailServerResponse is the response payload sent by the mailserver. // MailServerResponse is the response payload sent by the mailserver.
type MailServerResponse struct { type MailServerResponse struct {
LastEnvelopeHash statusproto.Hash LastEnvelopeHash protocol.Hash
Cursor []byte Cursor []byte
Error error Error error
} }

View File

@ -3,7 +3,7 @@ package whispertypes
import ( import (
"context" "context"
statusproto "github.com/status-im/status-go/protocol/types" protocol "github.com/status-im/status-go/protocol/types"
) )
// NewMessage represents a new whisper message that is posted through the RPC. // NewMessage represents a new whisper message that is posted through the RPC.
@ -48,7 +48,7 @@ type Criteria struct {
// use publicly without security implications. // use publicly without security implications.
type PublicWhisperAPI interface { type PublicWhisperAPI interface {
// AddPrivateKey imports the given private key. // AddPrivateKey imports the given private key.
AddPrivateKey(ctx context.Context, privateKey statusproto.HexBytes) (string, error) AddPrivateKey(ctx context.Context, privateKey protocol.HexBytes) (string, error)
// GenerateSymKeyFromPassword derives a key from the given password, stores it, and returns its ID. // GenerateSymKeyFromPassword derives a key from the given password, stores it, and returns its ID.
GenerateSymKeyFromPassword(ctx context.Context, passwd string) (string, error) GenerateSymKeyFromPassword(ctx context.Context, passwd string) (string, error)
// DeleteKeyPair removes the key with the given key if it exists. // DeleteKeyPair removes the key with the given key if it exists.

View File

@ -2,7 +2,7 @@ package whispertypes
import ( import (
"github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/hexutil"
statusproto "github.com/status-im/status-go/protocol/types" protocol "github.com/status-im/status-go/protocol/types"
) )
const ( const (
@ -32,12 +32,12 @@ func BytesToTopic(b []byte) (t TopicType) {
// String converts a topic byte array to a string representation. // String converts a topic byte array to a string representation.
func (t *TopicType) String() string { func (t *TopicType) String() string {
return statusproto.EncodeHex(t[:]) return protocol.EncodeHex(t[:])
} }
// MarshalText returns the hex representation of t. // MarshalText returns the hex representation of t.
func (t TopicType) MarshalText() ([]byte, error) { func (t TopicType) MarshalText() ([]byte, error) {
return statusproto.HexBytes(t[:]).MarshalText() return protocol.HexBytes(t[:]).MarshalText()
} }
// UnmarshalText parses a hex representation to a topic. // UnmarshalText parses a hex representation to a topic.

View File

@ -12,7 +12,7 @@ import (
"go.uber.org/zap" "go.uber.org/zap"
whispertypes "github.com/status-im/status-go/protocol/transport/whisper/types" whispertypes "github.com/status-im/status-go/protocol/transport/whisper/types"
statusproto "github.com/status-im/status-go/protocol/types" protocol "github.com/status-im/status-go/protocol/types"
) )
var ( var (
@ -372,7 +372,7 @@ func (a *WhisperServiceTransport) addSig(newMessage *whispertypes.NewMessage) er
func (a *WhisperServiceTransport) Track(identifiers [][]byte, hash []byte, newMessage *whispertypes.NewMessage) { func (a *WhisperServiceTransport) Track(identifiers [][]byte, hash []byte, newMessage *whispertypes.NewMessage) {
if a.envelopesMonitor != nil { if a.envelopesMonitor != nil {
a.envelopesMonitor.Add(identifiers, statusproto.BytesToHash(hash), *newMessage) a.envelopesMonitor.Add(identifiers, protocol.BytesToHash(hash), *newMessage)
} }
} }

View File

@ -1,3 +1,3 @@
# v1 statusproto package folder # v1 protocol package folder
This folder contains only data types mentioned in the specification and required for its implementation. This folder contains only data types mentioned in the specification and required for its implementation.

View File

@ -15,7 +15,7 @@ import (
"github.com/google/uuid" "github.com/google/uuid"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/status-im/status-go/protocol/crypto" "github.com/status-im/status-go/protocol/crypto"
statusproto "github.com/status-im/status-go/protocol/types" protocol "github.com/status-im/status-go/protocol/types"
) )
const ( const (
@ -94,7 +94,7 @@ func (u *MembershipUpdate) extractFrom() error {
if err != nil { if err != nil {
return errors.Wrap(err, "failed to extract signature") return errors.Wrap(err, "failed to extract signature")
} }
u.From = statusproto.EncodeHex(gethcrypto.FromECDSAPub(publicKey)) u.From = protocol.EncodeHex(gethcrypto.FromECDSAPub(publicKey))
return nil return nil
} }
@ -282,7 +282,7 @@ type Group struct {
} }
func groupChatID(creator *ecdsa.PublicKey) string { func groupChatID(creator *ecdsa.PublicKey) string {
return uuid.New().String() + "-" + statusproto.EncodeHex(gethcrypto.FromECDSAPub(creator)) return uuid.New().String() + "-" + protocol.EncodeHex(gethcrypto.FromECDSAPub(creator))
} }
func NewGroupWithMembershipUpdates(chatID string, updates []MembershipUpdate) (*Group, error) { func NewGroupWithMembershipUpdates(chatID string, updates []MembershipUpdate) (*Group, error) {
@ -396,7 +396,7 @@ func (g *Group) ProcessEvents(from *ecdsa.PublicKey, events []MembershipUpdateEv
} }
func (g *Group) ProcessEvent(from *ecdsa.PublicKey, event MembershipUpdateEvent) error { func (g *Group) ProcessEvent(from *ecdsa.PublicKey, event MembershipUpdateEvent) error {
fromHex := statusproto.EncodeHex(gethcrypto.FromECDSAPub(from)) fromHex := protocol.EncodeHex(gethcrypto.FromECDSAPub(from))
if !g.validateEvent(fromHex, event) { if !g.validateEvent(fromHex, event) {
return fmt.Errorf("invalid event %#+v from %s", event, from) return fmt.Errorf("invalid event %#+v from %s", event, from)
} }
@ -523,7 +523,7 @@ func stringSliceEquals(slice1, slice2 []string) bool {
} }
func publicKeyToString(publicKey *ecdsa.PublicKey) string { func publicKeyToString(publicKey *ecdsa.PublicKey) string {
return statusproto.EncodeHex(gethcrypto.FromECDSAPub(publicKey)) return protocol.EncodeHex(gethcrypto.FromECDSAPub(publicKey))
} }
type stringSet struct { type stringSet struct {

View File

@ -11,7 +11,7 @@ import (
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
"github.com/pkg/errors" "github.com/pkg/errors"
statusproto "github.com/status-im/status-go/protocol/types" protocol "github.com/status-im/status-go/protocol/types"
) )
const ( const (
@ -146,7 +146,7 @@ func EncodeMessage(value Message) ([]byte, error) {
// MessageID calculates the messageID from author's compressed public key // MessageID calculates the messageID from author's compressed public key
// and not encrypted but encoded payload. // and not encrypted but encoded payload.
func MessageID(author *ecdsa.PublicKey, data []byte) statusproto.HexBytes { func MessageID(author *ecdsa.PublicKey, data []byte) protocol.HexBytes {
keyBytes := crypto.FromECDSAPub(author) keyBytes := crypto.FromECDSAPub(author)
return crypto.Keccak256(append(keyBytes, data...)) return crypto.Keccak256(append(keyBytes, data...))
} }

View File

@ -68,7 +68,7 @@ func (m *StatusProtocolMessage) GetPayload() []byte {
} }
func init() { func init() {
proto.RegisterType((*StatusProtocolMessage)(nil), "statusproto.StatusProtocolMessage") proto.RegisterType((*StatusProtocolMessage)(nil), "protocol.StatusProtocolMessage")
} }
func init() { proto.RegisterFile("message.proto", fileDescriptor_33c57e4bae7b9afd) } func init() { proto.RegisterFile("message.proto", fileDescriptor_33c57e4bae7b9afd) }

View File

@ -12,7 +12,7 @@ import (
"github.com/status-im/status-go/protocol/datasync" "github.com/status-im/status-go/protocol/datasync"
"github.com/status-im/status-go/protocol/encryption" "github.com/status-im/status-go/protocol/encryption"
whispertypes "github.com/status-im/status-go/protocol/transport/whisper/types" whispertypes "github.com/status-im/status-go/protocol/transport/whisper/types"
statusproto "github.com/status-im/status-go/protocol/types" protocol "github.com/status-im/status-go/protocol/types"
) )
type StatusMessageT int type StatusMessageT int
@ -38,7 +38,7 @@ type StatusMessage struct {
DecryptedPayload []byte DecryptedPayload []byte
// ID is the canonical ID of the message // ID is the canonical ID of the message
ID statusproto.HexBytes ID protocol.HexBytes
// Hash is the transport layer hash // Hash is the transport layer hash
Hash []byte Hash []byte