core

package
Version: v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2020 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NonceDb

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

NonceDb is a collection of nonces with expiration dates.

func NewNonceDb

func NewNonceDb() *NonceDb

NewNonceDb creates an empty NonceDb.

func (*NonceDb) Add

func (ndb *NonceDb) Add(nonce string, delta int64, aux interface{}) *NonceObj

Add adds a nonce with aux data that expires after delta seconds

func (*NonceDb) AddAux

func (ndb *NonceDb) AddAux(nonce string, aux interface{}) bool

AddAux adds aux data to a nonceObj only if it doesn't have an Aux already. Returns true on success.

func (*NonceDb) DeleteOld

func (ndb *NonceDb) DeleteOld()

DeleteOld deletes all the expired nonces.

func (*NonceDb) DeleteOldOportunistic

func (ndb *NonceDb) DeleteOldOportunistic()

DeleteOldOportunistic deletes expired nonces once every N calls (where N is 128 for now).

func (*NonceDb) New

func (ndb *NonceDb) New(delta int64, aux interface{}) *NonceObj

New adds a new nonce to the db that expires after delta seconds, and returns the added NonceObj

func (*NonceDb) Search

func (ndb *NonceDb) Search(nonce string) (*NonceObj, bool)

Search searches a nonce object by nonce. Returns false if the nonce is not found or expired.

func (*NonceDb) SearchAndDelete

func (ndb *NonceDb) SearchAndDelete(nonce string) (*NonceObj, bool)

SearchAndDelete searches a nonce object by nonce, and if found, deletes it from the NonceDb. Returns false if the nonce is not found or expired.

type NonceObj

type NonceObj struct {
	Nonce      string
	Expiration int64
	Aux        interface{}
}

NonceObj represents a nonce with an expiration date and auxiliary data

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL