fossilizer

package
v0.4.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2020 License: Apache-2.0 Imports: 4 Imported by: 20

README

Fossilizer

A fossilizer takes arbitrary data and provides an externally-verifiable proof of existence for that data. It also provides a relative ordering of the events that produced fossilized data.

For example, a naive Bitcoin fossilizer could hash the given data and include it in a Bitcoin transaction. Since the Bitcoin blockchain is immutable, it provides a record that the data existed at block N.

See the Go documentation here.

Documentation

Overview

Package fossilizer defines types to implement a fossilizer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunExporter added in v0.3.1

func RunExporter(ctx context.Context, f Adapter, e EventExporter)

RunExporter connects the given exporter to the given fossilizer. RunExporter should run inside a go routine and will return when the context is cancelled.

Types

type Adapter

type Adapter interface {
	// Returns arbitrary information about the adapter.
	GetInfo(context.Context) (interface{}, error)

	// Adds a channel that receives events from the fossilizer
	AddFossilizerEventChan(chan *Event)

	// Requests data to be fossilized.
	// Meta is arbitrary data that will be forwarded to the websocket.
	Fossilize(ctx context.Context, data []byte, meta []byte) error
}

Adapter must be implemented by a fossilier.

type Event added in v0.2.0

type Event struct {
	EventType EventType
	Data      interface{}
}

Event is the object fossilizers send to notify of important events.

func (Event) Result added in v0.3.1

func (e Event) Result() (*Result, error)

Result converts the event data to a fossilizer.Result.

type EventExporter added in v0.3.1

type EventExporter interface {
	// Push an event to the exporter.
	Push(context.Context, *Event) error
}

EventExporter can be used to export events generated by a fossilizer.

type EventType added in v0.2.0

type EventType string

EventType lets you know the kind of event received. A client should ignore events it doesn't care about or doesn't understand.

const (
	// DidFossilize is sent when a piece of data was successfully fossilized.
	DidFossilize EventType = "DidFossilize"
)

type Fossil added in v0.3.1

type Fossil struct {
	// The data that was fossilized.
	Data []byte `json:"data"`

	// The metadata associated with the fossilized data.
	Meta []byte `json:"meta"`
}

Fossil that will be fossilized.

type FossilsQueue added in v0.3.1

type FossilsQueue interface {
	// Push a fossil to the queue.
	Push(context.Context, *Fossil) error

	// Pop fossils from the queue.
	Pop(context.Context, int) ([]*Fossil, error)
}

FossilsQueue can be used by batch fossilizers to store data that's pending fossilization. StorageQueue implementations can use persistent storage (like cloud queues) to prevent loss of data in cloud micro-services architecture.

type Result

type Result struct {
	// Evidence created by the fossilizer.
	Evidence chainscript.Evidence

	// The fossilized data.
	Fossil
}

Result is the type sent to the result channels.

Directories

Path Synopsis
Package fossilizerhttp is used to create an HTTP server from a fossilizer adapter.
Package fossilizerhttp is used to create an HTTP server from a fossilizer adapter.
Package fossilizertesting defines helpers to test fossilizers.
Package fossilizertesting defines helpers to test fossilizers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL