pow

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const BoltDBFile = "pow.db"

BoltDBFile is the filename to store the boltdb database

View Source
const BucketName = "pow"

BucketName is the bucket name to store the invitations on the bolt db

Variables

This section is empty.

Functions

This section is empty.

Types

type ProofOfWork

type ProofOfWork struct {
	Challenge string    `json:"challenge"`
	Bits      int       `json:"bits"`
	Proof     uint64    `json:"proof"`
	Expires   time.Time `json:"expires"`
	MsgID     string    `json:"msg_id"`
	Valid     bool      `json:"valid"`
}

ProofOfWork is the structure that keeps information about proof-of-work done for incoming messages. It connects the proof-of-work with a message ID which can be used for uploading.

type Storable

type Storable interface {
	// Retrieve retrieves the given challenge from the storage and returns its proof-of-work info
	Retrieve(challenge string) (*ProofOfWork, error)
	// Store stores the given proof of work in the storage
	Store(pow *ProofOfWork) error
	// Remove removes the given challenge from the storage
	Remove(challenge string) error
}

Storable interface is the main interface to store and retrieve proof-of-work

func NewBolt

func NewBolt(dbpath *string) Storable

NewBolt initializes a new repository

func NewRedis

func NewRedis(opts *redis.Options) Storable

NewRedis creates a new redis storage repository

Jump to

Keyboard shortcuts

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