sharding

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: Apache-2.0 Imports: 18 Imported by: 4

Documentation

Index

Constants

View Source
const EntryIDHexStringLen = TreeIDHexStringLen + UUIDHexStringLen
View Source
const TreeIDHexStringLen = 16
View Source
const UUIDHexStringLen = 64

Variables

View Source
var ErrPlainUUID = errors.New("cannot get treeID from plain UUID")

Functions

func GetTreeIDFromIDString added in v0.6.0

func GetTreeIDFromIDString(id string) (string, error)

GetTreeIDFromIDString Returns TreeID (with no appended UUID) from a TreeID or EntryID string. Validates TreeID and also UUID if present.

func GetUUIDFromIDString

func GetUUIDFromIDString(id string) (string, error)

GetUUIDFromIDString Returns UUID (with no prepended TreeID) from a UUID or EntryID string. Validates UUID and also TreeID if present.

func PadToTreeIDLen

func PadToTreeIDLen(t string) (string, error)

func TreeID added in v0.8.0

func TreeID(entryID string) (int64, error)

func ValidateEntryID added in v0.6.0

func ValidateEntryID(id string) error

func ValidateTreeID added in v0.6.0

func ValidateTreeID(t string) error

ValidateTreeID This is permissive in that if passed an EntryID, it will find the TreeID and validate it.

func ValidateUUID added in v0.6.0

func ValidateUUID(u string) error

ValidateUUID This is permissive in that if passed an EntryID, it will find the UUID and validate it.

func VirtualLogIndex added in v0.6.0

func VirtualLogIndex(leafIndex int64, tid int64, ranges *LogRanges) int64

VirtualLogIndex returns the virtual log index for a given leaf index

Types

type EntryID

type EntryID struct {
	TreeID string
	UUID   string
}

func CreateEntryIDFromParts

func CreateEntryIDFromParts(treeid string, uuid string) (EntryID, error)

CreateEntryIDFromParts This function can take a TreeID of equal or lesser length than TreeIDHexStringLen. In case the TreeID length is less than TreeIDHexStringLen, it will be padded to the correct length.

func (EntryID) ReturnEntryIDString

func (e EntryID) ReturnEntryIDString() string

type LogRange

type LogRange struct {
	TreeID        int64                      `json:"treeID" yaml:"treeID"`
	TreeLength    int64                      `json:"treeLength" yaml:"treeLength"`       // unused for active tree
	SigningConfig signer.SigningConfig       `json:"signingConfig" yaml:"signingConfig"` // if unset, assume same as active tree
	GRPCConfig    *trillianclient.GRPCConfig `json:"grpcEndpoint" yaml:"grpcEndpoint"`   // if unset, assume same as active tree
	Signer        signature.Signer
	PemPubKey     string // PEM-encoded PKIX public key
	LogID         string // Hex-encoded SHA256 digest of PKIX-encoded public key
}

LogRange represents a log or tree shard

func (LogRange) String added in v1.3.9

func (l LogRange) String() string

type LogRanges

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

Active and inactive shards

func NewLogRanges added in v0.6.0

func NewLogRanges(ctx context.Context, inactiveShardsPath string, activeTreeID int64, signingConfig signer.SigningConfig) (*LogRanges, error)

NewLogRanges initializes the active and any inactive log shards from a config file.

func (*LogRanges) AllShards added in v0.12.2

func (l *LogRanges) AllShards() []int64

AllShards returns all shards, starting with the active shard and then the inactive shards

func (*LogRanges) CompleteInitialization added in v1.4.1

func (l *LogRanges) CompleteInitialization(ctx context.Context, tcm *trillianclient.ClientManager) (map[int64]types.LogRootV1, error)

CompleteInitialization populates the tree length for all inactive shards.

func (*LogRanges) GetActive added in v0.6.0

func (l *LogRanges) GetActive() LogRange

GetActive returns the cative shard

func (*LogRanges) GetInactive added in v0.6.0

func (l *LogRanges) GetInactive() []LogRange

GetInactive returns all inactive shards

func (*LogRanges) GetLogRangeByTreeID added in v1.3.9

func (l *LogRanges) GetLogRangeByTreeID(treeID int64) (LogRange, error)

GetLogRangeByTreeID returns the active or inactive shard with the given tree ID

func (*LogRanges) NoInactive added in v0.6.0

func (l *LogRanges) NoInactive() bool

func (*LogRanges) PublicKey added in v0.6.0

func (l *LogRanges) PublicKey(treeID string) (string, error)

PublicKey returns the associated public key for the given Tree ID and returns the active public key by default

func (*LogRanges) ResolveVirtualIndex

func (l *LogRanges) ResolveVirtualIndex(index int) (int64, int64)

func (*LogRanges) String added in v0.6.0

func (l *LogRanges) String() string

func (*LogRanges) TotalInactiveLength added in v0.6.0

func (l *LogRanges) TotalInactiveLength() int64

TotalInactiveLength returns the total length across all inactive shards; we don't know the length of the active shard.

type Ranges added in v0.6.0

type Ranges []LogRange

Jump to

Keyboard shortcuts

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