db

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package db implements persistent storage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database interface {
	// EntityWithName returns the entity referenced by name
	EntityWithName(name string) (Entity, error)

	// SaveEntity saves a entity in the database
	SaveEntity(entity Entity) error

	// DeleteEntity deletes a entity from the database
	DeleteEntity(entity Entity)

	// Entities returns all entities
	Entities() ([]Entity, error)
}

Database stores entities

func NewDatabase

func NewDatabase(path string) (Database, error)

NewDatabase returns a database which stores data into the folder specified by the argument string.

func NewDatabaseWithStorage

func NewDatabaseWithStorage(storage util.Storage) Database

NewDatabaseWithStorage returns a database which uses the argument storage to store data.

func NewTempDatabase

func NewTempDatabase() (Database, error)

NewTempDatabase returns a temp database

type Entity

type Entity struct {
	Name       string
	PublicKey  []byte
	PrivateKey []byte
}

func NewEntity

func NewEntity(name string, publicKey, privateKey []byte) Entity

NewEntity returns a entity with a name, public and private key.

func NewRandomEntityWithName

func NewRandomEntityWithName(name string) (e Entity, err error)

NewRandomEntityWithName returns an entity with a random private and public keys

Jump to

Keyboard shortcuts

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