diff --git a/e2e/parse/partition.go b/e2e/parse/partition.go index 4850cafd70ffc44151ce2d93a2f698847b5b7571..0f3d1863014da49733d22ad93f478905e7387064 100644 --- a/e2e/parse/partition.go +++ b/e2e/parse/partition.go @@ -80,7 +80,7 @@ func (p *Partitioner) Partition(recipient *id.ID, mt catalog.MessageType, func (p *Partitioner) HandlePartition(sender *id.ID, contents []byte, relationshipFingerprint []byte, - residue e2eCrypto.KeyResidue) (receive.Message, bool) { + residue e2eCrypto.KeyResidue) (receive.Message, e2eCrypto.KeyResidue, bool) { if isFirst(contents) { // If it is the first message in a set, then handle it as so diff --git a/e2e/parse/partition/store.go b/e2e/parse/partition/store.go index 0f128c48206826b9553c3d75704a32ecf742bdd1..9db972575bb04a7349c113cb348173ab4bdce0eb 100644 --- a/e2e/parse/partition/store.go +++ b/e2e/parse/partition/store.go @@ -54,7 +54,7 @@ func (s *Store) AddFirst(partner *id.ID, mt catalog.MessageType, messageID uint64, partNum, numParts uint8, senderTimestamp, storageTimestamp time.Time, part []byte, relationshipFingerprint []byte, residue e2e.KeyResidue) ( - receive.Message, bool) { + receive.Message, e2e.KeyResidue, bool) { mpm := s.load(partner, messageID) mpm.AddFirst(mt, partNum, numParts, senderTimestamp, storageTimestamp, part) @@ -64,34 +64,39 @@ func (s *Store) AddFirst(partner *id.ID, mt catalog.MessageType, s.mux.Lock() defer s.mux.Unlock() + keyRes := e2e.KeyResidue{} if !ok { s.activeParts[mpm] = true s.saveActiveParts() } else { + keyRes = mpm.KeyResidue mpID := getMultiPartID(mpm.Sender, mpm.MessageID) delete(s.multiParts, mpID) } - return msg, ok + return msg, keyRes, ok } func (s *Store) Add(partner *id.ID, messageID uint64, partNum uint8, - part []byte, relationshipFingerprint []byte) (receive.Message, bool) { + part []byte, relationshipFingerprint []byte) ( + receive.Message, e2e.KeyResidue, bool) { mpm := s.load(partner, messageID) mpm.Add(partNum, part) msg, ok := mpm.IsComplete(relationshipFingerprint) + keyRes := e2e.KeyResidue{} if !ok { s.activeParts[mpm] = true s.saveActiveParts() } else { + keyRes = mpm.KeyResidue mpID := getMultiPartID(mpm.Sender, mpm.MessageID) delete(s.multiParts, mpID) } - return msg, ok + return msg, keyRes, ok } // prune clears old messages on it's stored timestamp. diff --git a/e2e/parse/partition_test.go b/e2e/parse/partition_test.go index 22c1f238eda4b2f2f0be5575e68143c28970a749..3abf6ff1f7db7d41eeaff31ba6dee0bcd3e82fb2 100644 --- a/e2e/parse/partition_test.go +++ b/e2e/parse/partition_test.go @@ -8,6 +8,7 @@ package parse import ( + "gitlab.com/elixxir/crypto/e2e" "testing" "gitlab.com/elixxir/client/catalog" @@ -72,10 +73,11 @@ func TestPartitioner_HandlePartition(t *testing.T) { p := NewPartitioner(versioned.NewKV(ekv.MakeMemstore()), len(ipsumTestStr)) m := newMessagePart(1107, 1, []byte(ipsumTestStr), len(ipsumTestStr)+headerLen) - _, _ = p.HandlePartition( + _, _, _ = p.HandlePartition( &id.DummyUser, m.bytes(), []byte{'t', 'e', 's', 't', 'i', 'n', 'g', 's', 't', 'r', 'i', 'n', 'g'}, + e2e.KeyResidue{}, ) } @@ -85,9 +87,10 @@ func TestPartitioner_HandleFirstPartition(t *testing.T) { m := newFirstMessagePart( catalog.XxMessage, 1107, 1, netTime.Now(), []byte(ipsumTestStr), len([]byte(ipsumTestStr))+firstHeaderLen) - _, _ = p.HandlePartition( + _, _, _ = p.HandlePartition( &id.DummyUser, m.bytes(), []byte{'t', 'e', 's', 't', 'i', 'n', 'g', 's', 't', 'r', 'i', 'n', 'g'}, + e2e.KeyResidue{}, ) }