Skip to content
Snippets Groups Projects
Commit 3b99642b authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Modify partioning to always produce messages of the cmix size

parent a438707b
Branches
Tags
3 merge requests!510Release,!207WIP: Client Restructure,!203Symmetric broadcast
......@@ -8,10 +8,11 @@
package conversation
import (
"sync"
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/storage/versioned"
"gitlab.com/xx_network/primitives/id"
"sync"
)
const conversationKeyPrefix = "conversation"
......
......@@ -9,8 +9,10 @@ package parse
import (
"encoding/binary"
"gitlab.com/elixxir/client/catalog"
"time"
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/catalog"
)
// Sizes of message parts, in bytes.
......@@ -36,10 +38,10 @@ type firstMessagePart struct {
// newFirstMessagePart creates a new firstMessagePart for the passed in
// contents. Does no length checks.
func newFirstMessagePart(mt catalog.MessageType, id uint32, numParts uint8,
timestamp time.Time, contents []byte) firstMessagePart {
timestamp time.Time, contents []byte, size int) firstMessagePart {
// Create the message structure
m := firstMessagePartFromBytes(make([]byte, len(contents)+firstHeaderLen))
m := firstMessagePartFromBytes(make([]byte, size))
// Set the message type
binary.BigEndian.PutUint32(m.Type, uint32(mt))
......@@ -81,6 +83,7 @@ func firstMessagePartFromBytes(data []byte) firstMessagePart {
// Map the data according to its version
version := data[len(data)-1]
jww.INFO.Printf("Unsafeversion: %d", version)
mapFunc, exists := firstMessagePartFromBytesVersions[version]
if exists {
return mapFunc(data)
......
......@@ -34,9 +34,10 @@ type messagePart struct {
// newMessagePart creates a new messagePart for the passed in contents. Does no
// length checks.
func newMessagePart(id uint32, part uint8, contents []byte) messagePart {
func newMessagePart(id uint32, part uint8, contents []byte,
size int) messagePart {
// Create the message structure
data := make([]byte, len(contents)+headerLen)
data := make([]byte, size)
m := messagePartFromBytes(data)
// Set the message ID
......
......@@ -8,6 +8,8 @@
package parse
import (
"time"
"github.com/pkg/errors"
"gitlab.com/elixxir/client/catalog"
"gitlab.com/elixxir/client/e2e/parse/conversation"
......@@ -16,7 +18,6 @@ import (
"gitlab.com/elixxir/client/storage/versioned"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/netTime"
"time"
)
const MaxMessageParts = 255
......@@ -64,12 +65,13 @@ func (p Partitioner) Partition(recipient *id.ID, mt catalog.MessageType,
// Create the first message part
var sub []byte
sub, payload = splitPayload(payload, p.firstContentsSize)
parts[0] = newFirstMessagePart(mt, messageID, numParts, timestamp, sub).bytes()
parts[0] = newFirstMessagePart(mt, messageID, numParts,
timestamp, sub, p.baseMessageSize).bytes()
// Create all subsequent message parts
for i := uint8(1); i < numParts; i++ {
sub, payload = splitPayload(payload, p.partContentsSize)
parts[i] = newMessagePart(messageID, i, sub).bytes()
parts[i] = newMessagePart(messageID, i, sub, p.baseMessageSize).bytes()
}
return parts, fullMessageID, nil
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment