timestamps

package
v0.0.0-...-865bf36 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2015 License: LGPL-2.1 Imports: 2 Imported by: 0

Documentation

Overview

Retrieval and processing of timestamps.

Includes a few simple implementations of the TimestampService interface, so that not every test needs the full setup work of, say, the BitcoinTimestampService (not yet implemented).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DummyTimestampService

type DummyTimestampService struct{}

Always successfully returns an empty timestamp list.

func (DummyTimestampService) GetTimestamps

func (tss DummyTimestampService) GetTimestamps() ([]string, error)

type PeerTimestampService

type PeerTimestampService struct {
	Doc *document.Document
}

A timestamp service that includes a Document pointer, and always returns the doc.Timestamps list.

Bandaid implementation for timestamps accumulated from peers.

func NewPeerTimestampService

func NewPeerTimestampService(doc *document.Document) PeerTimestampService

func (PeerTimestampService) GetTimestamps

func (sts PeerTimestampService) GetTimestamps() ([]string, error)

type SortingTimestampService

type SortingTimestampService struct {
	Doc document.Document
}

A timestamp service that includes a Document pointer, and always returns the sorted list of event hashes when you call GetTimestamps.

This is a useful approximation of real behavior for network-free testing, because the number of events will be small, and real timestamp services use hash sorting in any situation where the exact timing between two timestamps is ambiguous (multiple timestamps in the same block).

func NewSortingTimestampService

func NewSortingTimestampService(doc document.Document) SortingTimestampService

func (SortingTimestampService) GetTimestamps

func (sts SortingTimestampService) GetTimestamps() ([]string, error)

type TimestampService

type TimestampService interface {
	GetTimestamps() ([]string, error)
}

Different types of TimestampServices can be used, but the default implemetation makes use of the Bitcoin blockchain, given a bitcoind JSON-RPC location. Alternative timestamping services can simply be alternative blockchains, such as Litecoin, or something more exotic (if it can be made to fit the TimestampService interface).

See https://en.bitcoin.it/wiki/API_reference_%28JSON-RPC%29 for more information about this API.

type TimestampTracker

type TimestampTracker struct {
	Doc     *document.Document
	Service TimestampService
	// contains filtered or unexported fields
}

func NewTimestampTracker

func NewTimestampTracker(doc *document.Document, service TimestampService) TimestampTracker

func (*TimestampTracker) CompatibleWithTip

func (tt *TimestampTracker) CompatibleWithTip(event *document.Event) bool

func (*TimestampTracker) FindLatest

func (tt *TimestampTracker) FindLatest() (*document.Event, error)

Iterate until tip is found. Returns tip

Jump to

Keyboard shortcuts

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