db

package
v0.0.0-...-d0ade2f Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2022 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Debug bool
}

Config specifies service settings.

type DB

type DB interface {
	// Close closes DB
	Close() error

	// CreateSpecters creates the Specters DB if it doesn't exist
	CreateSpecters(context.Context, InstanceDB) error

	// GetSpecter gets a Specter from Specters DB
	GetSpecter(string, InstanceDB, PublicKeyDB) (InstanceDB, error)

	// HasSpecters returns if at least one specter exists
	HasSpecters() (bool, error)

	// CreateSpecter creates a Specter in Specters DB
	CreateSpecter(InstanceDB, PrivateKeyDB) (InstanceID, error)
}

DB is an interface for specters storage

func NewThreadsDB

func NewThreadsDB(store keytransform.TxnDatastoreExtended, network app.Net, config Config) (DB, error)

NewThreadsDB creates a new instance of ThreadsDB

type InstanceDB

type InstanceDB interface {
	// GetID gets the ID of InstanceDB
	GetID() InstanceID

	// SetID sets the ID on InstanceDB
	SetID(InstanceID)

	// SignInstance the given instance cryptographically.
	SignInstance(PrivateKeyDB) error

	// VerifyInstance that 'sig' is the signed hash of instance
	VerifyInstance(PublicKeyDB) (bool, error)
}

InstanceDB is an interface to sign and verify instances

type InstanceID

type InstanceID string

InstanceID is the type used in instance identities.

type PrivateKeyDB

type PrivateKeyDB interface {
	// Sign the given bytes cryptographically.
	Sign([]byte) ([]byte, error)

	// GetPublicDB returns the public key DB paired with this identity.
	GetPublicDB() PublicKeyDB
}

PrivateKeyDB is an interface to sign

type PublicKeyDB

type PublicKeyDB interface {
	// Verify that 'sig' is the signed hash of 'data'
	Verify([]byte, []byte) (bool, error)
}

PublicKeyDB is an interface to verify

type ThreadsDB

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

ThreadsDB is an implementation of Db using Textile Threads

func (*ThreadsDB) Close

func (t *ThreadsDB) Close() error

Close closes DB

func (*ThreadsDB) CreateSpecter

func (t *ThreadsDB) CreateSpecter(specter InstanceDB, privateKey PrivateKeyDB) (InstanceID, error)

CreateSpecter creates a Specter in Specters DB

func (*ThreadsDB) CreateSpecters

func (t *ThreadsDB) CreateSpecters(ctx context.Context, specter InstanceDB) error

CreateSpecters creates the Specters DB if it doesn't exist

func (*ThreadsDB) GetSpecter

func (t *ThreadsDB) GetSpecter(pubKey string, specter InstanceDB, publicKey PublicKeyDB) (InstanceDB, error)

GetSpecter gets a Specter from Specters DB

func (*ThreadsDB) HasSpecters

func (t *ThreadsDB) HasSpecters() (bool, error)

HasSpecters returns if at least one specter exists

Jump to

Keyboard shortcuts

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