ledger

package
v0.0.0-...-7635388 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: Apache-2.0 Imports: 7 Imported by: 3

Documentation

Overview

Package ledger implements a modified map with three unique characteristics: 1. every unique state of the map is given a unique hash 2. prior states of the map are retained for a fixed period of time 2. given a previous hash, we can retrieve a previous state from the map, if it is still retained.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ledger

type Ledger interface {
	// Put adds or overwrites a key in the Ledger
	Put(key, value string) (string, error)
	// Delete removes a key from the Ledger, which may still be read using GetPreviousValue
	Delete(key string) error
	// Get returns a the value of the key from the Ledger's current state
	Get(key string) (string, error)
	// RootHash is the hash of all keys and values currently in the Ledger
	RootHash() string
	// GetPreviousValue executes a get against a previous version of the ledger, using that version's root hash.
	GetPreviousValue(previousRootHash, key string) (result string, err error)
}

Ledger exposes a modified map with three unique characteristics: 1. every unique state of the map is given a unique hash 2. prior states of the map are retained for a fixed period of time 2. given a previous hash, we can retrieve a previous state from the map, if it is still retained.

func Make

func Make(retention time.Duration) Ledger

Make returns a Ledger which will retain previous nodes after they are deleted.

Jump to

Keyboard shortcuts

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