From 72c2f39216d8d8e9bce589271b38c76d16ee2a36 Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Tue, 25 Jan 2022 01:04:09 +0100 Subject: state: Refactor with new tree head endpoints For details see doc/proposals/2022-01-no-quick-tree-head-endpoint. --- pkg/state/state_manager.go | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'pkg/state/state_manager.go') diff --git a/pkg/state/state_manager.go b/pkg/state/state_manager.go index 5aa7609..ab0293c 100644 --- a/pkg/state/state_manager.go +++ b/pkg/state/state_manager.go @@ -6,11 +6,24 @@ import ( "git.sigsum.org/sigsum-lib-go/pkg/types" ) -// StateManager coordinates access to a log's tree heads and (co)signatures +// StateManager coordinates access to a log's tree heads and (co)signatures. type StateManager interface { - Latest(context.Context) (*types.SignedTreeHead, error) - ToSign(context.Context) (*types.SignedTreeHead, error) - Cosigned(context.Context) (*types.CosignedTreeHead, error) + // ToCosignTreeHead returns the log's to-cosign tree head + ToCosignTreeHead(context.Context) (*types.SignedTreeHead, error) + + // CosignedTreeHead returns the log's cosigned tree head + CosignedTreeHead(context.Context) (*types.CosignedTreeHead, error) + + // AddCosignature verifies that a cosignature is valid for the to-cosign + // tree head before adding it AddCosignature(context.Context, *types.PublicKey, *types.Signature) error + + // Run peridically rotates the log's to-cosign and cosigned tree heads Run(context.Context) } + +// event is a verified cosignature request +type event struct { + keyHash *types.Hash + cosignature *types.Signature +} -- cgit v1.2.3