package trees

import "github.com/google/trillian/trees"

Package trees contains utility method for retrieving trees and acquiring objects (hashers, signers) associated with them.

Index

Functions

func FromContext

func FromContext(ctx context.Context) (*trillian.Tree, bool)

FromContext returns the tree within ctx if present, together with an indication of whether a tree was present.

func GetTree

func GetTree(ctx context.Context, s storage.AdminStorage, treeID int64, opts GetOpts) (*trillian.Tree, error)

GetTree returns the specified tree, either from the ctx (if present) or read from storage. The tree will be validated according to GetOpts before returned. Tree state is also considered (for example, deleted tree will return NotFound errors).

func Hash

func Hash(tree *trillian.Tree) (crypto.Hash, error)

Hash returns the crypto.Hash configured by the tree.

func NewContext

func NewContext(ctx context.Context, tree *trillian.Tree) context.Context

NewContext returns a ctx with the given tree.

func Signer

func Signer(ctx context.Context, tree *trillian.Tree) (*tcrypto.Signer, error)

Signer returns a Trillian crypto.Signer configured by the tree.

Types

type GetOpts

type GetOpts struct {
	// TreeType is the expected type of the tree. Use trillian.TreeType_UNKNOWN_TREE_TYPE to
	// allow any type.
	TreeType trillian.TreeType
	// Readonly is whether the tree will be used for read-only purposes.
	Readonly bool
}

GetOpts contains validation options for GetTree.

Source Files

trees.go

Version
v1.0.2
Published
Oct 10, 2017
Platform
js/wasm
Imports
10 packages
Last checked
2 hours ago

Tools for package owners.