Skip to content
Snippets Groups Projects
Commit db61d3f6 authored by Josh Brooks's avatar Josh Brooks
Browse files

Finish refactor of SendE2e

parent 14cfca30
No related branches found
No related tags found
2 merge requests!510Release,!344Xx 4084/send e2e residue
...@@ -85,7 +85,7 @@ func (c *Cmix) Connect(e2eId int, recipientContact, e2eParamsJSON []byte) ( ...@@ -85,7 +85,7 @@ func (c *Cmix) Connect(e2eId int, recipientContact, e2eParamsJSON []byte) (
// - []byte - the JSON marshalled bytes of the E2ESendReport object, which can // - []byte - the JSON marshalled bytes of the E2ESendReport object, which can
// be passed into Cmix.WaitForRoundResult to see if the send succeeded. // be passed into Cmix.WaitForRoundResult to see if the send succeeded.
func (c *Connection) SendE2E(mt int, payload []byte) ([]byte, error) { func (c *Connection) SendE2E(mt int, payload []byte) ([]byte, error) {
rounds, mid, ts, keyResidue, err := c.connection.SendE2E(catalog.MessageType(mt), payload, sendReport, err := c.connection.SendE2E(catalog.MessageType(mt), payload,
c.params.Base) c.params.Base)
if err != nil { if err != nil {
...@@ -93,10 +93,10 @@ func (c *Connection) SendE2E(mt int, payload []byte) ([]byte, error) { ...@@ -93,10 +93,10 @@ func (c *Connection) SendE2E(mt int, payload []byte) ([]byte, error) {
} }
sr := E2ESendReport{ sr := E2ESendReport{
RoundsList: makeRoundsList(rounds...), RoundsList: makeRoundsList(sendReport.RoundList...),
MessageID: mid.Marshal(), MessageID: sendReport.MessageId.Marshal(),
Timestamp: ts.UnixNano(), Timestamp: sendReport.SentTime.UnixNano(),
KeyResidue: keyResidue.Marshal(), KeyResidue: sendReport.KeyResidue.Marshal(),
} }
return json.Marshal(&sr) return json.Marshal(&sr)
......
...@@ -486,7 +486,7 @@ func miscConnectionFunctions(user *xxdk.E2e, conn connect.Connection) { ...@@ -486,7 +486,7 @@ func miscConnectionFunctions(user *xxdk.E2e, conn connect.Connection) {
conn.GetPartner().PartnerId()) conn.GetPartner().PartnerId())
payload := []byte(msgBody) payload := []byte(msgBody)
for { for {
roundIDs, _, _, _, err := conn.SendE2E(catalog.XxMessage, payload, sendReport, err := conn.SendE2E(catalog.XxMessage, payload,
paramsE2E) paramsE2E)
if err != nil { if err != nil {
jww.FATAL.Panicf("[CONN] Failed to send E2E message: %v", err) jww.FATAL.Panicf("[CONN] Failed to send E2E message: %v", err)
...@@ -494,7 +494,7 @@ func miscConnectionFunctions(user *xxdk.E2e, conn connect.Connection) { ...@@ -494,7 +494,7 @@ func miscConnectionFunctions(user *xxdk.E2e, conn connect.Connection) {
// Verify message sends were successful when verifySendFlag is present // Verify message sends were successful when verifySendFlag is present
if viper.GetBool(verifySendFlag) { if viper.GetBool(verifySendFlag) {
if !verifySendSuccess(user, paramsE2E, roundIDs, if !verifySendSuccess(user, paramsE2E, sendReport.RoundList,
conn.GetPartner().PartnerId(), payload) { conn.GetPartner().PartnerId(), payload) {
continue continue
} }
......
...@@ -98,7 +98,7 @@ func connectWithAuthentication(conn Connection, timeStart time.Time, ...@@ -98,7 +98,7 @@ func connectWithAuthentication(conn Connection, timeStart time.Time,
} }
// Send message to server // Send message to server
rids, _, _, _, err := conn.SendE2E(catalog.ConnectionAuthenticationRequest, sendReport, err := conn.SendE2E(catalog.ConnectionAuthenticationRequest,
payload, clientE2e.GetDefaultParams()) payload, clientE2e.GetDefaultParams())
if err != nil { if err != nil {
// Close connection on an error // Close connection on an error
...@@ -139,7 +139,7 @@ func connectWithAuthentication(conn Connection, timeStart time.Time, ...@@ -139,7 +139,7 @@ func connectWithAuthentication(conn Connection, timeStart time.Time,
// Track the result of the round(s) we sent the // Track the result of the round(s) we sent the
// identity authentication message on // identity authentication message on
err = net.GetRoundResults(remainingTime, err = net.GetRoundResults(remainingTime,
roundCb, rids...) roundCb, sendReport.RoundList...)
if err != nil { if err != nil {
return nil, errors.Errorf("could not track rounds for successful " + return nil, errors.Errorf("could not track rounds for successful " +
"identity confirmation message delivery") "identity confirmation message delivery")
......
...@@ -16,7 +16,6 @@ import ( ...@@ -16,7 +16,6 @@ import (
"gitlab.com/elixxir/comms/network" "gitlab.com/elixxir/comms/network"
"gitlab.com/elixxir/crypto/contact" "gitlab.com/elixxir/crypto/contact"
"gitlab.com/elixxir/crypto/cyclic" "gitlab.com/elixxir/crypto/cyclic"
cryptoE2e "gitlab.com/elixxir/crypto/e2e"
"gitlab.com/elixxir/primitives/format" "gitlab.com/elixxir/primitives/format"
"gitlab.com/xx_network/comms/connect" "gitlab.com/xx_network/comms/connect"
"gitlab.com/xx_network/crypto/large" "gitlab.com/xx_network/crypto/large"
...@@ -115,8 +114,7 @@ func (m *mockConnection) Close() error { ...@@ -115,8 +114,7 @@ func (m *mockConnection) Close() error {
func (m *mockConnection) GetPartner() partner.Manager { return m.partner } func (m *mockConnection) GetPartner() partner.Manager { return m.partner }
func (m *mockConnection) SendE2E( func (m *mockConnection) SendE2E(
mt catalog.MessageType, payload []byte, _ e2e.Params) ( mt catalog.MessageType, payload []byte, _ e2e.Params) (e2e.SendReport, error) {
[]id.Round, cryptoE2e.MessageID, time.Time, cryptoE2e.KeyResidue, error) {
m.payloadChan <- payload m.payloadChan <- payload
m.listener.Hear(receive.Message{ m.listener.Hear(receive.Message{
MessageType: mt, MessageType: mt,
...@@ -124,7 +122,7 @@ func (m *mockConnection) SendE2E( ...@@ -124,7 +122,7 @@ func (m *mockConnection) SendE2E(
Sender: m.partner.myID, Sender: m.partner.myID,
RecipientID: m.partner.partnerId, RecipientID: m.partner.partnerId,
}) })
return nil, cryptoE2e.MessageID{}, time.Time{}, cryptoE2e.KeyResidue{}, nil return e2e.SendReport{}, nil
} }
func (m *mockConnection) RegisterListener( func (m *mockConnection) RegisterListener(
......
...@@ -45,7 +45,7 @@ func sendNewFileTransferMessage( ...@@ -45,7 +45,7 @@ func sendNewFileTransferMessage(
params.LastServiceTag = catalog.Silent params.LastServiceTag = catalog.Silent
params.DebugTag = initialMessageDebugTag params.DebugTag = initialMessageDebugTag
_, _, _, _, err := connectionHandler.SendE2E( _, err := connectionHandler.SendE2E(
catalog.NewFileTransfer, transferInfo, params) catalog.NewFileTransfer, transferInfo, params)
if err != nil { if err != nil {
return errors.Errorf(errNewFtSendE2e, err) return errors.Errorf(errNewFtSendE2e, err)
...@@ -65,7 +65,7 @@ func sendEndFileTransferMessage(cmix ft.Cmix, connectionHandler connection) { ...@@ -65,7 +65,7 @@ func sendEndFileTransferMessage(cmix ft.Cmix, connectionHandler connection) {
params.LastServiceTag = catalog.EndFT params.LastServiceTag = catalog.EndFT
params.DebugTag = lastMessageDebugTag params.DebugTag = lastMessageDebugTag
_, _, _, _, err := connectionHandler.SendE2E( _, err := connectionHandler.SendE2E(
catalog.EndFileTransfer, nil, params) catalog.EndFileTransfer, nil, params)
if err != nil { if err != nil {
jww.ERROR.Printf(errEndFtSendE2e, err) jww.ERROR.Printf(errEndFtSendE2e, err)
......
...@@ -26,7 +26,6 @@ import ( ...@@ -26,7 +26,6 @@ import (
"gitlab.com/elixxir/client/xxdk" "gitlab.com/elixxir/client/xxdk"
"gitlab.com/elixxir/comms/network" "gitlab.com/elixxir/comms/network"
"gitlab.com/elixxir/crypto/cyclic" "gitlab.com/elixxir/crypto/cyclic"
e2eCrypto "gitlab.com/elixxir/crypto/e2e"
"gitlab.com/elixxir/crypto/fastRNG" "gitlab.com/elixxir/crypto/fastRNG"
"gitlab.com/elixxir/ekv" "gitlab.com/elixxir/ekv"
"gitlab.com/elixxir/primitives/format" "gitlab.com/elixxir/primitives/format"
...@@ -38,7 +37,6 @@ import ( ...@@ -38,7 +37,6 @@ import (
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id/ephemeral" "gitlab.com/xx_network/primitives/id/ephemeral"
"gitlab.com/xx_network/primitives/ndf" "gitlab.com/xx_network/primitives/ndf"
"gitlab.com/xx_network/primitives/netTime"
"sync" "sync"
"testing" "testing"
"time" "time"
...@@ -268,8 +266,7 @@ func (m *mockConnection) GetPartner() partner.Manager { ...@@ -268,8 +266,7 @@ func (m *mockConnection) GetPartner() partner.Manager {
// SendE2E adds the message to the e2e handler map. // SendE2E adds the message to the e2e handler map.
func (m *mockConnection) SendE2E(mt catalog.MessageType, payload []byte, func (m *mockConnection) SendE2E(mt catalog.MessageType, payload []byte,
_ e2e.Params) ([]id.Round, e2eCrypto.MessageID, time.Time, _ e2e.Params) (e2e.SendReport, error) {
e2eCrypto.KeyResidue, error) {
m.handler.Lock() m.handler.Lock()
defer m.handler.Unlock() defer m.handler.Unlock()
...@@ -279,8 +276,7 @@ func (m *mockConnection) SendE2E(mt catalog.MessageType, payload []byte, ...@@ -279,8 +276,7 @@ func (m *mockConnection) SendE2E(mt catalog.MessageType, payload []byte,
Sender: m.myID, Sender: m.myID,
}) })
return []id.Round{42}, e2eCrypto.MessageID{}, netTime.Now(), return e2e.SendReport{RoundList: []id.Round{42}}, nil
e2eCrypto.KeyResidue{}, nil
} }
func (m *mockConnection) RegisterListener(mt catalog.MessageType, func (m *mockConnection) RegisterListener(mt catalog.MessageType,
......
...@@ -13,9 +13,7 @@ import ( ...@@ -13,9 +13,7 @@ import (
"gitlab.com/elixxir/client/e2e/ratchet/partner" "gitlab.com/elixxir/client/e2e/ratchet/partner"
"gitlab.com/elixxir/client/e2e/receive" "gitlab.com/elixxir/client/e2e/receive"
ft "gitlab.com/elixxir/client/fileTransfer" ft "gitlab.com/elixxir/client/fileTransfer"
e2eCrypto "gitlab.com/elixxir/crypto/e2e"
ftCrypto "gitlab.com/elixxir/crypto/fileTransfer" ftCrypto "gitlab.com/elixxir/crypto/fileTransfer"
"gitlab.com/xx_network/primitives/id"
"time" "time"
) )
...@@ -41,7 +39,7 @@ type Wrapper struct { ...@@ -41,7 +39,7 @@ type Wrapper struct {
type connection interface { type connection interface {
GetPartner() partner.Manager GetPartner() partner.Manager
SendE2E(mt catalog.MessageType, payload []byte, params e2e.Params) ( SendE2E(mt catalog.MessageType, payload []byte, params e2e.Params) (
[]id.Round, e2eCrypto.MessageID, time.Time, e2eCrypto.KeyResidue, error) e2e.SendReport, error)
RegisterListener(messageType catalog.MessageType, RegisterListener(messageType catalog.MessageType,
newListener receive.Listener) (receive.ListenerID, error) newListener receive.Listener) (receive.ListenerID, error)
} }
......
...@@ -46,7 +46,7 @@ func sendNewFileTransferMessage( ...@@ -46,7 +46,7 @@ func sendNewFileTransferMessage(
params.LastServiceTag = catalog.Silent params.LastServiceTag = catalog.Silent
params.DebugTag = initialMessageDebugTag params.DebugTag = initialMessageDebugTag
_, _, _, _, err := e2eHandler.SendE2E( _, err := e2eHandler.SendE2E(
catalog.NewFileTransfer, recipient, transferInfo, params) catalog.NewFileTransfer, recipient, transferInfo, params)
if err != nil { if err != nil {
return errors.Errorf(errNewFtSendE2e, err) return errors.Errorf(errNewFtSendE2e, err)
...@@ -66,7 +66,7 @@ func sendEndFileTransferMessage(recipient *id.ID, cmix ft.Cmix, e2eHandler e2eHa ...@@ -66,7 +66,7 @@ func sendEndFileTransferMessage(recipient *id.ID, cmix ft.Cmix, e2eHandler e2eHa
params.LastServiceTag = catalog.EndFT params.LastServiceTag = catalog.EndFT
params.DebugTag = lastMessageDebugTag params.DebugTag = lastMessageDebugTag
_, _, _, _, err := e2eHandler.SendE2E( _, err := e2eHandler.SendE2E(
catalog.EndFileTransfer, recipient, nil, params) catalog.EndFileTransfer, recipient, nil, params)
if err != nil { if err != nil {
jww.ERROR.Printf(errEndFtSendE2e, err) jww.ERROR.Printf(errEndFtSendE2e, err)
......
...@@ -28,7 +28,6 @@ import ( ...@@ -28,7 +28,6 @@ import (
"gitlab.com/elixxir/client/xxdk" "gitlab.com/elixxir/client/xxdk"
"gitlab.com/elixxir/comms/network" "gitlab.com/elixxir/comms/network"
"gitlab.com/elixxir/crypto/cyclic" "gitlab.com/elixxir/crypto/cyclic"
e "gitlab.com/elixxir/crypto/e2e"
"gitlab.com/elixxir/crypto/fastRNG" "gitlab.com/elixxir/crypto/fastRNG"
"gitlab.com/elixxir/ekv" "gitlab.com/elixxir/ekv"
"gitlab.com/elixxir/primitives/format" "gitlab.com/elixxir/primitives/format"
...@@ -40,7 +39,6 @@ import ( ...@@ -40,7 +39,6 @@ import (
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id/ephemeral" "gitlab.com/xx_network/primitives/id/ephemeral"
"gitlab.com/xx_network/primitives/ndf" "gitlab.com/xx_network/primitives/ndf"
"gitlab.com/xx_network/primitives/netTime"
"sync" "sync"
"time" "time"
) )
...@@ -259,7 +257,7 @@ func (m *mockE2e) StartProcesses() (stoppable.Stoppable, error) { panic("impleme ...@@ -259,7 +257,7 @@ func (m *mockE2e) StartProcesses() (stoppable.Stoppable, error) { panic("impleme
// SendE2E adds the message to the e2e handler map. // SendE2E adds the message to the e2e handler map.
func (m *mockE2e) SendE2E(mt catalog.MessageType, recipient *id.ID, func (m *mockE2e) SendE2E(mt catalog.MessageType, recipient *id.ID,
payload []byte, _ e2e.Params) ([]id.Round, e.MessageID, time.Time, e.KeyResidue, error) { payload []byte, _ e2e.Params) (e2e.SendReport, error) {
m.handler.listeners[mt].Hear(receive.Message{ m.handler.listeners[mt].Hear(receive.Message{
MessageType: mt, MessageType: mt,
...@@ -268,7 +266,7 @@ func (m *mockE2e) SendE2E(mt catalog.MessageType, recipient *id.ID, ...@@ -268,7 +266,7 @@ func (m *mockE2e) SendE2E(mt catalog.MessageType, recipient *id.ID,
RecipientID: recipient, RecipientID: recipient,
}) })
return []id.Round{42}, e.MessageID{}, netTime.Now(), e.KeyResidue{}, nil return e2e.SendReport{RoundList: []id.Round{42}}, nil
} }
func (m *mockE2e) RegisterListener(_ *id.ID, mt catalog.MessageType, func (m *mockE2e) RegisterListener(_ *id.ID, mt catalog.MessageType,
......
...@@ -12,7 +12,6 @@ import ( ...@@ -12,7 +12,6 @@ import (
"gitlab.com/elixxir/client/e2e" "gitlab.com/elixxir/client/e2e"
"gitlab.com/elixxir/client/e2e/receive" "gitlab.com/elixxir/client/e2e/receive"
ft "gitlab.com/elixxir/client/fileTransfer" ft "gitlab.com/elixxir/client/fileTransfer"
e2eCrypto "gitlab.com/elixxir/crypto/e2e"
ftCrypto "gitlab.com/elixxir/crypto/fileTransfer" ftCrypto "gitlab.com/elixxir/crypto/fileTransfer"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"time" "time"
...@@ -39,8 +38,7 @@ type Wrapper struct { ...@@ -39,8 +38,7 @@ type Wrapper struct {
// for easier testing. // for easier testing.
type e2eHandler interface { type e2eHandler interface {
SendE2E(mt catalog.MessageType, recipient *id.ID, payload []byte, SendE2E(mt catalog.MessageType, recipient *id.ID, payload []byte,
params e2e.Params) ([]id.Round, e2eCrypto.MessageID, time.Time, params e2e.Params) (e2e.SendReport, error)
e2eCrypto.KeyResidue, error)
RegisterListener(senderID *id.ID, messageType catalog.MessageType, RegisterListener(senderID *id.ID, messageType catalog.MessageType,
newListener receive.Listener) receive.ListenerID newListener receive.Listener) receive.ListenerID
} }
......
...@@ -120,13 +120,13 @@ func (m *manager) sendRequest(memberID *id.ID, request []byte) ([]id.Round, erro ...@@ -120,13 +120,13 @@ func (m *manager) sendRequest(memberID *id.ID, request []byte) ([]id.Round, erro
p.LastServiceTag = catalog.GroupRq p.LastServiceTag = catalog.GroupRq
p.DebugTag = "group.Request" p.DebugTag = "group.Request"
rounds, _, _, _, err := m.getE2eHandler().SendE2E( sendReport, err := m.getE2eHandler().SendE2E(
catalog.GroupCreationRequest, memberID, request, p) catalog.GroupCreationRequest, memberID, request, p)
if err != nil { if err != nil {
return nil, errors.Errorf(sendE2eErr, memberID, err) return nil, errors.Errorf(sendE2eErr, memberID, err)
} }
return rounds, nil return sendReport.RoundList, nil
} }
// roundIdMap2List converts the map of round IDs to a list of round IDs. // roundIdMap2List converts the map of round IDs to a list of round IDs.
......
...@@ -55,7 +55,7 @@ func respond(response *restlike.Message, conn connect.Connection) error { ...@@ -55,7 +55,7 @@ func respond(response *restlike.Message, conn connect.Connection) error {
} }
// TODO: Parameterize params // TODO: Parameterize params
_, _, _, _, err = conn.SendE2E(catalog.XxMessage, payload, e2e.GetDefaultParams()) _, err = conn.SendE2E(catalog.XxMessage, payload, e2e.GetDefaultParams())
if err != nil { if err != nil {
return errors.Errorf("unable to send restlike response message: %+v", err) return errors.Errorf("unable to send restlike response message: %+v", err)
} }
......
...@@ -50,7 +50,7 @@ func (s *Request) Request(method restlike.Method, path restlike.URI, ...@@ -50,7 +50,7 @@ func (s *Request) Request(method restlike.Method, path restlike.URI,
// Transmit the Message // Transmit the Message
// fixme: should this use the key residue? // fixme: should this use the key residue?
_, _, _, _, err = s.Net.SendE2E(catalog.XxMessage, msg, e2eParams) _, err = s.Net.SendE2E(catalog.XxMessage, msg, e2eParams)
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -85,7 +85,6 @@ func (s *Request) AsyncRequest(method restlike.Method, path restlike.URI, ...@@ -85,7 +85,6 @@ func (s *Request) AsyncRequest(method restlike.Method, path restlike.URI,
s.Net.RegisterListener(catalog.XxMessage, &response{responseCallback: cb}) s.Net.RegisterListener(catalog.XxMessage, &response{responseCallback: cb})
// Transmit the Message // Transmit the Message
// fixme: should this use the key residue? _, err = s.Net.SendE2E(catalog.XxMessage, msg, e2eParams)
_, _, _, _, err = s.Net.SendE2E(catalog.XxMessage, msg, e2eParams)
return err return err
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment