-
Notifications
You must be signed in to change notification settings - Fork 23
Meta Templates
For nodes and software to be able to work together we need some common framework. We do this my establishing meta template. A meta template meta information in a a JSON format. For example, this is some meta information used on the current prototype of Metadisk.
{
"datetime": "1398875062",
"filehash": "b17fee6427ee665eb54159762fe03847792af1d94bf6769b82f95b95e82975d2",
"filename": "b17fee6_WhatisStorj.pdf",
"filesize": 337748,
"uploads": [
{
"host_name": "ge_tt",
"url": "http://ge.tt/162T7Ef1/v/0"
},
{
"host_name": "gfile_ru",
"url": "http://gfile.ru/a4WfC"
},
{
"host_name": "rghost",
"url": "http://rghost.net/54761561"
}
],
"version": "0.2"
}All nodes on the network can view this meta information. So if you asked a Storj node, like Metadisk, for the file with the hash b17fee6427ee665eb54159762fe03847792af1d94bf6769b82f95b95e82975d2 it would retrieve this information, then retrieve the specified file for you.
We can do this through the current API: http://node2.storj.io/api/download/b17fee6427ee665eb54159762fe03847792af1d94bf6769b82f95b95e82975d2
If the information was missing fields or in the incorrect format then the nodes would not be able to function correctly. We establish a meta contract so everyone can work from a standardized format.
{
"name": "metadisk-template-a",
"genesis": "DFTz9F3YEp4psg5JC9qoxDnRputPk45UTQ",
"filehash": <string>,
"filename": <string>,
"filesize": <int>,
"uploads": [
{
"host_name": <string>,
"url": <string>
},
{
"host_name": <string>,
"url": <string>
},
{
"error": <string>,
"url": <string>
}
]
}We send this data as a transaction to a metachain, like Datacoin. The first transaction to the genesis address must be the template. Generally transactions matching the template of first transaction will be sent to the genesis address listed in the template. If they don't fit the template, they will be ignored by the software.
Any applications running off a metachain does not have to store the full blockchain. They simply have to store block headers for the chain, and then watch the genesis address of their application for transactions that they can act upon.
Now we can sent transactions to the blockchain, and reference our template so that everyone can agree on the format. The txid of this particular template in the Datacoin blockchain is c42bc134e94387caf9f685a01560aa020890233a80e6d2208a1cab2f72e190bb. The new metadata that we send to the blockchain looks something like this:
{
"name": "metadisk-template-a",
"template": "c42bc134e94387caf9f685a01560aa020890233a80e6d2208a1cab2f72e190bb",
"filehash": "b17fee6427ee665eb54159762fe03847792af1d94bf6769b82f95b95e82975d2",
"filename": "b17fee6_WhatisStorj.pdf",
"filesize": 337748,
"uploads": [
{
"host_name": "ge_tt",
"url": "http://ge.tt/162T7Ef1/v/0"
},
{
"host_name": "gfile_ru",
"url": "http://gfile.ru/a4WfC"
},
{
"host_name": "rghost",
"url": "http://rghost.net/54761561"
}
],
"version": "0.2"
}Note that we include the txid of the template in our metadata. Once the template has been placed in the blockchain it can't be changed. Therefore nodes and software can easily process data with the same template because they will know exactly what to expect.
Powered by Storj.