factom: github.com/Factom-Asset-Tokens/factom/fat107 Index | Files

package fat107

import "github.com/Factom-Asset-Tokens/factom/fat107"

Index

Package Files

generate.go metadata.go

Constants

const (
    Protocol = "data-store"
    Version  = "1.0"
)

Current Protocol and Version.

const (
    MaxDBIEHashCount       = factom.EntryMaxDataSize / 32
    MaxLinkedDBIEHashCount = (factom.EntryMaxDataSize - 32 - 2) / 32
)

func Generate Uses

func Generate(ctx context.Context, es factom.EsAddress,
    cData io.Reader, compression *Compression,
    dataSize uint64, dataHash *factom.Bytes32,
    appMetadata json.RawMessage, appNamespace ...factom.Bytes) (
    chainID factom.Bytes32,
    txIDs, entryHashes []factom.Bytes32,
    commits, reveals []factom.Bytes,
    totalCost uint,
    err error)

Generate a set of Data Store Chain Entries for the data read from cData.

The data from cData may be compressed using zlib or gzip, and if so, compression must be initialized with the correct Format and Size. See Compression for more details.

The size must be the size of the uncompressed data.

The given dataHash must be the sha256d hash of the uncompressed data.

The appMetadata and appNamespace are optional. The appMetadata is included in the JSON stored in the content of the First Entry, and the appNamespace is appended to the ExtIDs of the First Entry and so must be known, along with the dataHash, for a client to recompute the ChainID.

The new Data Store chainID is returned, along with the commits and reveals required to create the Data Store Chain, and the totalCost in Entry Credits of creating the Data Store.

func NameIDs Uses

func NameIDs(dataHash *factom.Bytes32, namespace ...factom.Bytes) []factom.Bytes

NameIDs constructs the valid Data Store NameIDs for data with the given dataHash and namespace.

Pass the result to factom.ComputeChainID to derive the Data Store Chain ID.

type Compression Uses

type Compression struct {
    // Compression format used on the data. May be "gzip" or "zlib".
    Format string `json:"format"`

    // The size of the compressed data. This is what is actually stored on
    // the Data Store Chain.
    Size uint64 `json:"size"`
}

Compression describes compression settings for how the Data is stored.

type Metadata Uses

type Metadata struct {
    // The sha256d hash of the Data.
    DataHash *factom.Bytes32 `json:"-"`

    // The First Entry of the Data Store Chain, from which this Metadata
    // was parsed.
    Entry factom.Entry `json:"-"`

    // The Version of the Data Store protocol.
    Version string `json:"data-store"`

    // The total uncompressed size of the Data. If there are no compression
    // settings, this is what is actually stored on the Data Store Chain.
    Size uint64 `json:"size"`

    // Optional compression settings describing how the Data is stored.
    *Compression `json:"compression,omitempty"`

    // The Entry Hash of the first DBI Entry that describing the Data.
    DBIStart *factom.Bytes32 `json:"dbi-start"`

    // Optional additional JSON containing application defined Metadata.
    AppMetadata json.RawMessage `json:"metadata,omitempty"`
}

Metadata describes the Data from a Data Store Chain.

func Lookup Uses

func Lookup(ctx context.Context, c *factom.Client,
    chainID *factom.Bytes32) (Metadata, error)

Lookup the Metadata for a given Data Store chainID.

func ParseEntry Uses

func ParseEntry(e factom.Entry) (Metadata, error)

ParseEntry attempts to parse e as the First Entry from a Data Store Chain.

func (Metadata) Download Uses

func (m Metadata) Download(ctx context.Context, c *factom.Client, data io.Writer) error

Download all Data Block Index and Data Block Entries required to reconstruct the on chain data, and then decompresses the data if necessary before writing it to the given data io.Writer.

The Data Block Entries are downloaded concurrently as they are loaded from the DBI.

The sha256d hash of the data written to data, is verified.

Package fat107 imports 12 packages (graph). Updated 2020-03-24. Refresh now. Tools for package owners.