state

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2020 License: Unlicense Imports: 9 Imported by: 0

Documentation

Overview

Package state implements the state of a hashchain.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type State

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

State hold the state of a hashchain.

func New

func New(pubKey, comment string) *State

New returns a new state for pubKey with optional comment.

func (*State) AddLinkHash

func (s *State) AddLinkHash(linkHash [32]byte, lineNumber int)

AddLinkHash adds linkHash with lineNumber to state.

func (*State) AddSigner

func (s *State) AddSigner(pubKey [32]byte, weight int, comment string)

AddSigner adds pubKey with weight to state (unconfirmed).

func (*State) AddSourceHash

func (s *State) AddSourceHash(linkHash, treeHash, pubKey [32]byte, comment string)

AddSourceHash adds treeHash at given linkHash to state.

func (*State) HasLinkHash

func (s *State) HasLinkHash(linkHash [32]byte) bool

HasLinkHash checks wether the state s contains the given linkHash.

func (*State) HasSigner

func (s *State) HasSigner(pubKey [32]byte) bool

HasSigner checks wether the state s contains a valid the signer with pubKey.

func (*State) HeadN

func (s *State) HeadN() int

HeadN returns the total weight of all signers, including unconfirmed key additions and removals.

func (*State) LastSignedTreeHash

func (s *State) LastSignedTreeHash() (string, int)

LastSignedTreeHash returns the last signed tree hash.

func (*State) LastTreeHash

func (s *State) LastTreeHash() string

LastTreeHash returns the most current tree hash.

func (*State) LinkHash

func (s *State) LinkHash(treeHash string) [32]byte

LinkHash returns the link hash corresponding to given treeHash.

func (*State) LinkHashes

func (s *State) LinkHashes() int

LinkHashes returns the number of link hashes contained in state.

func (*State) M

func (s *State) M() int

M returns the signature threshold.

func (*State) N

func (s *State) N() int

N returns the total weight of all signers.

func (*State) NotPublished

func (s *State) NotPublished(treeHash string) error

NotPublished makes sure that the given treeHash has not been published before (unconfirmed or confirmed).

func (*State) NotSigner

func (s *State) NotSigner(pubKey [32]byte) error

NotSigner makes sure the given pubKey is not a signer (unconfirmed or confirmed).

func (*State) OPs

func (s *State) OPs() int

OPs returns the number of operations in the hash chain.

func (*State) RemoveSigner

func (s *State) RemoveSigner(pubKey [32]byte) error

RemoveSigner removes pubKey with weight (must equal last addition) from state (unconfirmed).

func (*State) SetSignatureControl

func (s *State) SetSignatureControl(m int)

SetSignatureControl sets new signature control m (unconfirmed).

func (*State) Sign

func (s *State) Sign(linkHash, pubKey [32]byte) error

Sign signs the given linkHash with pubKey.

func (*State) Signer

func (s *State) Signer() map[string]bool

Signer returns a containing all active signers for state.

func (*State) SignerBarrier

func (s *State) SignerBarrier(pubKey string) int

SignerBarrier returns the signer barrier for pubKey.

func (*State) SignerComment

func (s *State) SignerComment(pubKey string) string

SignerComment returns the signer comment for given pubKey.

func (*State) SignerWeight

func (s *State) SignerWeight(pubKey string) int

SignerWeight returns the signer weight for given pubKey.

func (*State) SourceLine

func (s *State) SourceLine(treeHash string) int

SourceLine returns the line number where the given tree hash was signed.

func (*State) TreeComments

func (s *State) TreeComments() []string

TreeComments returns a list of all tree comments in order (starting from tree.EmptyHash).

func (*State) TreeHashes

func (s *State) TreeHashes() []string

TreeHashes returns a list of all tree hashes in order (starting from tree.EmptyHash).

func (*State) UnsignedInfo

func (s *State) UnsignedInfo(pubKey, treeHash string, omitSource bool) ([]string, error)

UnsignedInfo returns a string slice with information about all unsigned entries suitable for printing. If TreeHash is defined it returns info until that treeHash. If omitSource is true source lines are omitted

Jump to

Keyboard shortcuts

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