archiver

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2019 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

archiver takes transactions and settings, collects them to blocks, calculates hash of blocks, creates archives, pushes hash to some blockchain(s), uploads archives to external storage

you can easily verify block hash by command: tar xf archive.tar -O --wildcards "*/settings" "*/txns" | sha256sum
you can even get hasher command like this: `tar xf archive.tar -O --wildcards "*/metadata.json" | jq -r .HashType`sum
and by the same way you can extract block hash: tar xf archiver.tar -O --wildcards "*/metadata.json" | jq -r .Hash

DB buckets

Txns   : <block_hash>/<type>/<txn_id> -> <txn json>
Index  : <type>/<txn_id> -> <block_hash>
Blocks : <block_hash> -> <block>

Index

Constants

View Source
const (
	TxnsBucket   = "txns"
	BlocksBucket = "blocks"
	IndexBucket  = "idx"

	TxnsDir     = "txns"
	SettingsDir = "settings"

	LastBlock = "last"
)
View Source
const (
	HashSHA256 = "sha256"
)

Variables

This section is empty.

Functions

func Handler

func Handler(a *Archiver) http.Handler

Types

type Archiver

type Archiver struct {
	// contains filtered or unexported fields
}

func New

func New(db *bolt.DB, rotateSize int) (*Archiver, error)

func (*Archiver) Block

func (a *Archiver) Block(ctx context.Context, hash BlockHash) (*BlockMeta, error)

func (*Archiver) CheckSettings

func (a *Archiver) CheckSettings(ctx context.Context, tid pt.SettingsID) (*BlockMeta, error)

func (*Archiver) CheckTxn

func (a *Archiver) CheckTxn(ctx context.Context, tid pt.TxnID) (*BlockMeta, error)

func (*Archiver) LastBlock

func (a *Archiver) LastBlock(ctx context.Context) (*BlockMeta, error)

func (*Archiver) Push

func (a *Archiver) Push(ctx context.Context, txns []pt.Txn) error

func (*Archiver) PushSettings

func (a *Archiver) PushSettings(ctx context.Context, sett *pt.Settings) error

func (*Archiver) Rotate

func (a *Archiver) Rotate() error

func (*Archiver) SetMinio

func (a *Archiver) SetMinio(c *MinioConfig) error

func (*Archiver) Start

func (a *Archiver) Start(d time.Duration) error

type BlockHash

type BlockHash [sha256.Size]byte
var ZeroBlockHash BlockHash

func NewBlockHash

func NewBlockHash(h []byte) BlockHash

func NewBlockHashFromString

func NewBlockHashFromString(s string) BlockHash

NewBlockHashFromString is not safe, it can be used only for tests or constants

func (BlockHash) MarshalJSON

func (h BlockHash) MarshalJSON() ([]byte, error)

func (BlockHash) String

func (h BlockHash) String() string

func (*BlockHash) UnmarshalJSON

func (h *BlockHash) UnmarshalJSON(data []byte) error

type BlockMeta

type BlockMeta struct {
	Hash     BlockHash `json:"hash"`
	PrevHash BlockHash `json:"prev_hash"`
	Time     string    `json:"time"`

	StorageBucket string `json:"storage_bucket,omitempty"`
	StoragePath   string `json:"storage_path,omitempty"`

	Status Status `json:"status"`

	HashType HashType `json:"hash_type"`
}

type HashType

type HashType string

type MinioConfig

type MinioConfig struct {
	Bucket   string
	Prefix   string
	Location string

	Client *minio.Client
}

type Status

type Status int
const (
	NOTFOUND Status = iota
	UNPROCESSED
	PREPROCESSED
	FIXED
	UPLOADED
)

func (Status) Bytes

func (s Status) Bytes() []byte

func (Status) String

func (i Status) String() string

Jump to

Keyboard shortcuts

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