Documentation ¶
Index ¶
Constants ¶
const ( ErrorOK = 0 // Everything's cool ErrorExists = 1 // Digest exists ErrorNotFound = 2 // Generic not found error ErrorNotAllowed = 3 // Generic not allowed error )
const ( RecordTypeDigestReceived = "digest" RecordTypeDigestReceivedGlobal = "digestglobal" RecordTypeFlushRecord = "flush" RecordTypeVersion = 1 )
Record types.
Variables ¶
var ( ErrTryAgainLater = errors.New("busy, try again later") ErrTimestampNotFound = errors.New("timestamp not found") )
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface { // Return timestamp information for given digests. Get([][sha256.Size]byte) ([]GetResult, error) // Return all hashes for given timestamps. GetTimestamps([]int64) ([]TimestampResult, error) // Store hashes and return timestamp and associated errors. Put is // allowed to return transient errors. Put([][sha256.Size]byte) (int64, []PutResult, error) // Close performs cleanup of the backend. Close() // Dump dumps database to the provided file descriptor. If the // human flag is set to true it pretty prints the database content // otherwise it dumps a JSON stream. Dump(*os.File, bool) error // Restore recreates the the database from the provided file // descriptor. The verbose flag is set to true to indicate that this // call may parint to stdout. The provided string describes the target // location and is implementation specific. Restore(*os.File, bool, string) error // Fsck walks all data and verifies its integrity. In addition it // verifies anchored timestamps' existence on the blockchain. Fsck(*FsckOptions) error }
type DigestReceived ¶
type DigestReceived struct { Digest string `json:"digest"` // Digest that was flushed Timestamp int64 `json:"timestamp"` // Server received timestamp }
DigestReceived describes when a digest was received by the server.
type FlushRecord ¶
type FlushRecord struct { Root [sha256.Size]byte // Merkle root Hashes []*[sha256.Size]byte // All digests Tx chainhash.Hash // Tx that anchored merkle tree ChainTimestamp int64 // Blockchain timestamp, if available FlushTimestamp int64 // Time flush actually happened }
FlushRecord contains blockchain information. This information only becomes available once digests are anchored in the blockchain. The information contained in this record is subject to change due to blockchain realities (e.g. a fork).
type FlushRecordJSON ¶
type FlushRecordJSON struct { Root [sha256.Size]byte `json:"root"` // Merkle root Hashes []*[sha256.Size]byte `json:"hashes"` // All digests Tx chainhash.Hash `json:"tx"` // Tx that anchored merkle tree ChainTimestamp int64 `json:"chaintimestamp"` // Blockchain timestamp, if available FlushTimestamp int64 `json:"flushtimestamp"` // Time flush actually happened Timestamp int64 `json:"timestamp,omitempty"` // Timestamp received }
FlushRecordJSON is identical to FlushRecord but with corrected JSON capitalization. At some point the DB needs to start using this type instead of broken one. Timestamp is optional based on the backend.
type FsckOptions ¶
type FsckOptions struct { Verbose bool // Normal verbosity PrintHashes bool // Prints every hash Fix bool // Fix fixable errors URL string // URL for fnodata, used to verify anchors File string // Path for results file }
FsckOptions provides generic options on how to handle an fsck. Sane defaults will be used in lieu of options being provided.
type GetResult ¶
type GetResult struct { Digest [sha256.Size]byte // Digest ErrorCode uint // Error code Timestamp int64 // Server timestamp AnchoredTimestamp int64 // Anchored timestamp Tx chainhash.Hash // Anchor Tx MerkleRoot [sha256.Size]byte // Merkle root MerklePath merkle.Branch // Auth path }
GetResult is a cooked result returned by the backend.
type RecordType ¶
type RecordType struct { Version uint `json:"version"` // Version of RecordType Type string `json:"type"` // Type or record }
RecordType indicates what the next record is in a restore stream. All records are dumped prefixed with a RecordType so that they can be simply replayed as a journal.
type TimestampResult ¶
type TimestampResult struct { Timestamp int64 // Collection timestamp ErrorCode uint // Overall result AnchoredTimestamp int64 // Anchored timestamp Tx chainhash.Hash // Anchor Tx MerkleRoot [sha256.Size]byte // Merkle root Digests [][sha256.Size]byte // All digests }
TimestampResult is a cooked error returned by the backend.