Multipart Message Format

From OIP Wiki
Jump to: navigation, search

Multipart messages take the initial Message data and split it up into chunks that will fit inside of the Florincoin blockchain.

For example, if someones Artifact publish message was 800 bytes instead of being <528 bytes, then it would need to be "broken up" in order for the information to be stored inside of the Florincoin Blockchain. In this example, there would be ~2-3 transactions pushed to the Florincoin blockchain, each with a portion of the overall message data.

Create Message Parts

Since the overall message we want to publish to the blockchain is > 528 bytes (the Maximum tx-comment allowed by Florincoin), we need to split it up into multiple transactions. In order to figure out how many parts/transactions we need, we need to split up the string into chunks of ~370 characters. We chop it down to ~370 characters in order to be able to fit the extra information being sent with the Multipart message (part numbers, address, txid reference, and the signature).

Javascript code to Split String

var CHOP_MAX_LEN = 370;
var chopString = function (input) {
	input = input.toString();

	var chunks = [];
	while (input.length > CHOP_MAX_LEN) {
		chunks[chunks.length] = input.slice(0, CHOP_MAX_LEN);
		input = input.slice(CHOP_MAX_LEN);
	chunks[chunks.length] = input;

	return chunks;

How to create a Multipart Message

Each multipart message follows this format:

oip-mp($partNumber, $multipartArrayLength, $publisherAddress, $firstPartTXID, $signature):$choppedStringData

  • oip-mp: Prefix of Multipart Message
  • $partNumber: The position in the "split" tx string array.
  • $multipartArrayLength: Total number of parts in the "split" tx string array.
  • $publisherAddress: The Florincoin Address of the user publishing the message to the blockchain.
  • $firstPartTXID: The TXID of the first "part". This is the txid for the first multipart message that gets sent, this is how we link Multipart messages together.
  • $signature: A message signed with the $publisherAddress that is built by taking the following:
    • $partNumber-$multipartArrayLength-$publisherAddress-$firstPartTXID-$choppedStringData
  • $choppedStringData: The string found at $partNumber in the "split" tx string array.