### Example Usage: Omniwitness Load Test Setup Source: https://pkg.go.dev/github.com/transparency-dev/witness/cmd/loadtest This example demonstrates the full workflow: generating log keys and configuration, starting the omniwitness with the generated config, and then running the load test against it. The omniwitness is left running in the background after its setup. ```bash # Generate log keys and configuration go run ./cmd/loadtest/ --log_count=50 > /tmp/logs.yaml # Run the omniwitness with the generated config. This leaves the process running in the background! go run ./cmd/omniwitness \ -v=1 \ --alsologtostderr \ --private_key=PRIVATE+KEY+HammerMe+4447e4a4+AZjU0/B7AorRLJHVqRaWaWExHbRQKWgUDb8Bf9NEpee7 \ --additional_logs=/tmp/logs.yaml \ --poll_interval=0 \ --db_file=/tmp/hammerwit.db & # Run the load test against the witness go run ./cmd/loadtest/ \ --target=http://localhost:8080 \ --log_count=50 \ --timeout=5s ``` -------------------------------- ### Run Omniwitness in Bastion Mode Source: https://pkg.go.dev/github.com/transparency-dev/witness/cmd/omniwitness Example command to run omniwitness with bastion support. Ensure to set `--bastion_addr` to the bastion host's address and `--bastion_key_path` to the private key file. Set `--poll_interval` to 0 for bastion-only mode. ```bash # Example flags for running omniwitness with bastion support: omniwitness --bastion_addr=localhost:8080 --bastion_key_path=./my_bastion_private_key.pem --poll_interval=0 ``` -------------------------------- ### Start OmniGCP Witness Service Source: https://pkg.go.dev/github.com/transparency-dev/witness/cmd/omniwitness_gcp Run the OmniGCP witness binary on a GCP VM. Ensure the SPANNER and SECRET environment variables are set to the resource names of your Spanner database and Secret Manager secret, respectively. ```bash export SPANNER="projects/..." # This is the spanner resource name of the existing database. export SECRET="projects/..." # This is the secret manager secret name. go run ./cmd/omniwitness_gcp/ --signer_private_key_secret_name=${SECRET} --spanner=${SPANNER} ``` -------------------------------- ### Example Witnessed Checkpoint Source: https://pkg.go.dev/github.com/transparency-dev/witness An example of a witnessed checkpoint showing signatures from the log and multiple witnesses. This format is used to verify the append-only nature of logs. ```text developers.google.com/android/binary_transparency/0 611 2GZ1zmS5VkfUZmn2ZyR4KZXwHLD+xnwBIWzql/cD50w= — pixel_transparency_log csh42zBFAiAd3Y1FwqNTt5RglY0uG7heC6Yu1gEbXXPYmZ7LdOILMAIhAIt68PnR/3TADAaC7hvrSHbpziV7TmpIwOUydLmcjyTQ — ArmoredWitness-small-breeze nRq5UQAAAABnoqrsRIofXn68vTohcAm2KG4ACGyRPNePUk02BSWD0WKV5ElejTk5Z+Tm3GmJ5j/etA+fkL9XuaQsnTyZbr437sF4AQ== — ArmoredWitness-autumn-wood qZb5XQAAAABnoqrl57G9CblEl3lwwuqzbaJvVMqNiZCbYZseYT1YZHYmls3CmT1wxZ1fNgM4RxHuUxjAwcI2ghTx6R5aCg+L0DGPBA== ``` -------------------------------- ### Get Metric Factory - Witness Monitoring Source: https://pkg.go.dev/github.com/transparency-dev/witness/monitoring Returns the singleton MetricFactory for the application. Avoid calling this during static initialization. Recommended to use with sync.Once. ```go func GetMetricFactory() MetricFactory ``` -------------------------------- ### Run OmniWitness Standalone with Flags Source: https://pkg.go.dev/github.com/transparency-dev/witness/cmd/omniwitness Run the OmniWitness binary directly without Docker, configuring it via command-line flags. This setup allows for basic operation where witnessed checkpoints are accessible via HTTP endpoints. ```bash go run github.com/transparency-dev/witness/cmd/omniwitness@main --alsologtostderr --v=1 \ --private_key_path ./path/to/private_key_in_vkey_format \ --db_file ~/witness.db ``` -------------------------------- ### FetchProofFn Type - witness/feeder Source: https://pkg.go.dev/github.com/transparency-dev/witness/internal/feeder FetchProofFn is the signature of a function that fetches a consistency proof. It takes a context, a starting checkpoint number, and an ending checkpoint, returning the proof data and any error encountered. ```go type FetchProofFn func(ctx context.Context, from uint64, to log.Checkpoint) ([][]byte, error) ``` -------------------------------- ### OmniWitness Docker Compose Environment Variables Source: https://pkg.go.dev/github.com/transparency-dev/witness/cmd/omniwitness Environment variables for the Docker Compose setup of the OmniWitness. Ensure the private key path is correctly set. ```env WITNESS_PRIVATE_KEY_PATH=./path/to/private_key_in_vkey_format WITNESS_VERSION=latest ``` -------------------------------- ### SumDBClient.FullLeavesAtOffset Source: https://pkg.go.dev/github.com/transparency-dev/witness/internal/client Fetches a chunk of leaves (2^height) starting from a specified offset. ```APIDOC ## FullLeavesAtOffset ### Description FullLeavesAtOffset gets the Nth chunk of 2**height leaves. ### Signature func (c *SumDBClient) FullLeavesAtOffset(offset int) ([][]byte, error) ``` -------------------------------- ### Get Checkpoint Source: https://pkg.go.dev/github.com/transparency-dev/witness/internal/witness Retrieves a checkpoint for a specified log, ensuring it is consistent with other checkpoints for the same log signed by this witness. ```APIDOC ## GetCheckpoint ### Description Gets a checkpoint for a given log, which is consistent with all other checkpoints for the same log signed by this witness. Returns a nil checkpoint if no checkpoint is stored for the given logID. ### Signature ```go func (w *Witness) GetCheckpoint(ctx context.Context, origin string) ([]byte, error) ``` ### Parameters - **ctx** (context.Context) - The context for the operation. - **origin** (string) - The identifier of the log for which to retrieve the checkpoint. ``` -------------------------------- ### Main Source: https://pkg.go.dev/github.com/transparency-dev/witness/omniwitness Main runs the omniwitness, with the witness listening using the listener, and all outbound HTTP calls using the client provided. ```APIDOC ## Main ### Description Runs the omniwitness service. ### Signature ```go func Main(ctx context.Context, operatorConfig OperatorConfig, p Persistence, httpListener net.Listener, httpClient *http.Client) error ``` ``` -------------------------------- ### New Witness Function Source: https://pkg.go.dev/github.com/transparency-dev/witness/internal/witness Creates and initializes a new Witness instance. It takes context and options as parameters. ```go func New(ctx context.Context, wo Opts) (*Witness, error) ``` -------------------------------- ### Proof Marshal Method Source: https://pkg.go.dev/github.com/transparency-dev/witness/internal/witness Marshals the Proof into its common format string representation. ```go func (p Proof) Marshal() string ``` -------------------------------- ### Config struct for bastion connection Source: https://pkg.go.dev/github.com/transparency-dev/witness/internal/bastion Configuration for connecting to the bastion service. Includes address, prefix, private key, and a verifier. ```go type Config struct { Addr string Prefix string BastionKey ed25519.PrivateKey WitnessVerifier note.Verifier } ``` -------------------------------- ### NewSumDB Client Constructor Source: https://pkg.go.dev/github.com/transparency-dev/witness/internal/client Creates a new SumDBClient instance. It requires the desired tree height, a verifier, the SumDB URL, and an HTTP client. ```go func NewSumDB(height int, verifier note.Verifier, url string, c *http.Client) *SumDBClient ``` -------------------------------- ### NewWitness Constructor Source: https://pkg.go.dev/github.com/transparency-dev/witness/client/http Creates a new Witness client. It requires a URL to the witness and an http.Client to use for requests. ```go func NewWitness(url *url.URL, c *http.Client) Witness ``` -------------------------------- ### Main Function Signature Source: https://pkg.go.dev/github.com/transparency-dev/witness/omniwitness The Main function is the entry point for running the omniwitness service. It accepts context, operator configuration, persistence, an HTTP listener, and an HTTP client. ```go func Main(ctx context.Context, operatorConfig OperatorConfig, p Persistence, httpListener net.Listener, httpClient *http.Client) error ``` -------------------------------- ### Run Load Test Against Witness Source: https://pkg.go.dev/github.com/transparency-dev/witness/cmd/loadtest Execute the loadtest tool pointing at a running witness instance. Ensure the witness is configured to trust the keys generated by the loadtest tool. ```go go run ./cmd/loadtest/ --target=http://localhost:8080 --log_count=50 ``` -------------------------------- ### PublicFetchOpts Structure Source: https://pkg.go.dev/github.com/transparency-dev/witness/omniwitness PublicFetchOpts holds options for fetching public witness network configuration. ```APIDOC ## PublicFetchOpts Structure ### Description The `PublicFetchOpts` struct contains options used when fetching public witness network configuration files. ### Fields - **Client** (*http.Client) - The HTTP client to use. If unset, `http.DefaultClient` is used. - **URL** (string) - The URL of the configuration file to fetch. ``` -------------------------------- ### New Static Log Configuration Source: https://pkg.go.dev/github.com/transparency-dev/witness/omniwitness Creates a new LogConfig from provided YAML data. Use this to initialize log configurations programmatically. ```go func NewStaticLogConfig(yamlCfg []byte) (*staticLogConfig, error) ``` -------------------------------- ### Generate Logs Configuration with Loadtest Source: https://pkg.go.dev/github.com/transparency-dev/witness/cmd/loadtest Run the loadtest tool without a target to generate cryptographic keys for simulated logs and output the required YAML configuration. Redirect this output to a file for later use in witness configuration. ```go go run ./cmd/loadtest/ --log_count=50 > /tmp/logs.yaml ``` -------------------------------- ### RunFeedOpts Struct Definition Source: https://pkg.go.dev/github.com/transparency-dev/witness/omniwitness Configuration options for running feeders. Includes settings for maximum QPS, HTTP client, log matching, feeder configurations, and target witnesses. ```go type RunFeedOpts struct { // MaxWitnessQPS is the maximum number of requests to make per second to any given witness. // If unset, a default of 1 QPS will be assumed. MaxWitnessQPS float64 // HTTPClient is the HTTPClient to use, if nil uses http.DefaultClient. HTTPClient *http.Client // MatchLogs is an optional regex to select a submet of logs to feed. MatchLogs string // FeederConfigs provides access to feeder configs. Required. FeederConfigs func(context.Context) iter.Seq2[FeederConfig, error] // Witnesses is the set of witnesses to feed to. Required. Witnesses []Witness } ``` -------------------------------- ### NewSumDB Source: https://pkg.go.dev/github.com/transparency-dev/witness/internal/client Creates a new SumDB client instance. It requires an initial height, a verifier for security, the SumDB URL, and an optional HTTP client. ```APIDOC ## NewSumDB ### Description Creates a new client that fetches tiles of the given height. ### Signature func NewSumDB(height int, verifier note.Verifier, url string, c *http.Client) *SumDBClient ``` -------------------------------- ### Witness Opts Struct Source: https://pkg.go.dev/github.com/transparency-dev/witness/internal/witness Defines the configuration options for creating a new witness instance. It includes persistence, signers, and a verifier function. ```go type Opts struct { Persistence persistence.LogStatePersistence Signers []note.Signer VerifierForLog func(ctx context.Context, origin string) (note.Verifier, bool, error) } ``` -------------------------------- ### FetchPublicConfig Function Source: https://pkg.go.dev/github.com/transparency-dev/witness/omniwitness Fetches public log configurations from a remote source. Use this to dynamically load log details. ```go func FetchPublicConfig(ctx context.Context, opts PublicFetchOpts) ([]Log, error) ``` -------------------------------- ### Register bastion connection Source: https://pkg.go.dev/github.com/transparency-dev/witness/internal/bastion Connects to the bastion to receive checkpoints. Retries on broken connections and returns when the context is done. ```go func Register(ctx context.Context, c Config, witnessHandler http.Handler) error ``` -------------------------------- ### PublicFetchOpts Struct Definition Source: https://pkg.go.dev/github.com/transparency-dev/witness/omniwitness Holds options for fetching public witness network configurations. Allows specifying an HTTP client and the URL of the config file. ```go type PublicFetchOpts struct { // Client is the HTTP client to be used, if unset uses http.DefaultClient. Client *http.Client // URL is the URL of the config file. URL string } ``` -------------------------------- ### MetricFactory Interface - Witness Monitoring Source: https://pkg.go.dev/github.com/transparency-dev/witness/monitoring Defines the interface for creating different types of metrics. Use this to abstract metric creation. ```go type MetricFactory interface { NewCounter(name, help string, labelNames ...string) Counter } ``` -------------------------------- ### Witness Update Method Source: https://pkg.go.dev/github.com/transparency-dev/witness/client/http Attempts to advance the witness state. It takes the current size, new checkpoint data, and a proof. Returns the HTTP status code, response body, or an error. ```go func (w Witness) Update(ctx context.Context, oldSize uint64, newCP []byte, proof [][]byte) ([]byte, uint64, error) ``` -------------------------------- ### Proof Unmarshal Method Source: https://pkg.go.dev/github.com/transparency-dev/witness/internal/witness Unmarshals common proof format data into the Proof struct. Returns an error if parsing fails. ```go func (p *Proof) Unmarshal(data []byte) error ``` -------------------------------- ### New Witness Creation Source: https://pkg.go.dev/github.com/transparency-dev/witness/internal/witness Creates a new witness instance. Initially, the witness will not follow any logs. ```APIDOC ## New ### Description Creates a new witness, which initially has no logs to follow. ### Signature ```go func New(ctx context.Context, wo Opts) (*Witness, error) ``` ### Parameters - **ctx** (context.Context) - The context for the operation. - **wo** (Opts) - The options to configure the witness. ``` -------------------------------- ### ConfigYAML Structure Source: https://pkg.go.dev/github.com/transparency-dev/witness/omniwitness Represents the YAML configuration structure for logs, containing a list of LogYAML. ```go type ConfigYAML struct { Logs []LogYAML `yaml:"Logs"` } ``` -------------------------------- ### RunFeedOpts Structure Source: https://pkg.go.dev/github.com/transparency-dev/witness/omniwitness RunFeedOpts configures the options for running feeders. ```APIDOC ## RunFeedOpts Structure ### Description The `RunFeedOpts` struct defines the configuration parameters for running feeders, including rate limits, HTTP client settings, log matching, and the set of witnesses to feed. ### Fields - **MaxWitnessQPS** (float64) - The maximum number of requests per second to any given witness. Defaults to 1 QPS if unset. - **HTTPClient** (*http.Client) - The HTTP client to use. If nil, `http.DefaultClient` is used. - **MatchLogs** (string) - An optional regular expression to filter which logs to feed. - **FeederConfigs** (func(context.Context) iter.Seq2[FeederConfig, error]) - Required function to access feeder configurations. - **Witnesses** ([]Witness) - Required slice of `Witness` structs representing the targets to feed. ``` -------------------------------- ### ParsePublicWitnessConfig Function Source: https://pkg.go.dev/github.com/transparency-dev/witness/omniwitness Parses the public witness configuration from an io.Reader. Implements the parser for the public witness config format. ```go func ParsePublicWitnessConfig(r io.Reader) ([]Log, error) ``` -------------------------------- ### SumDBClient LatestCheckpoint Method Source: https://pkg.go.dev/github.com/transparency-dev/witness/internal/client Fetches the most recent checkpoint from the SumDB log. ```go func (c *SumDBClient) LatestCheckpoint() (*Checkpoint, error) ``` -------------------------------- ### Interactively Feed Checkpoints to Witness Source: https://pkg.go.dev/github.com/transparency-dev/witness/cmd/omniwitness Use the `feedwitness` command to send checkpoints to your omniwitness instance for testing. Adjust the `--witness_url` if your witness is not running on `http://localhost:8080`. ```bash # Change the --witness_url value to point to your witness instance if necessary go run github.com/transparency-dev/witness/cmd/feedwitness@main --alsologtostderr --witness_url=http://localhost:8080 ``` -------------------------------- ### SumDBClient TileData Method Source: https://pkg.go.dev/github.com/transparency-dev/witness/internal/client Fetches raw tile data from the SumDB log at a specific level and offset. Supports fetching partial tiles. ```go func (c *SumDBClient) TileData(level, offset, partial int) ([]byte, error) ``` -------------------------------- ### InertCounter Implementation - Witness Monitoring Source: https://pkg.go.dev/github.com/transparency-dev/witness/monitoring An internal-only implementation of the Counter interface, useful for testing or scenarios where metrics are not actively collected. ```go type InertCounter struct { // contains filtered or unexported fields } ``` -------------------------------- ### Source Struct - witness/feeder Source: https://pkg.go.dev/github.com/transparency-dev/witness/internal/feeder Source holds parameters for calling the Feed function. It includes functions to fetch checkpoints and proofs, a verifier for log signatures, and the expected origin of the log. ```go type Source struct { // FetchCheckpoint should return a recent checkpoint from the source log. FetchCheckpoint func(ctx context.Context) ([]byte, error) // FetchProof should return a consistency proof from the source log. // // Note that if the witness knows the log but has no previous checkpoint stored, this // function will be called with a default `from` value - this allows compact-range // type proofs to be supported. Implementations for non-compact-range type proofs // should return an empty proof and no error. FetchProof FetchProofFn // LogSigVerifier a verifier for log checkpoint signatures. LogSigVerifier note.Verifier // LogOrigin is the expected first line of checkpoints from the source log. LogOrigin string } ``` -------------------------------- ### FetchPublicConfig Source: https://pkg.go.dev/github.com/transparency-dev/witness/omniwitness FetchPublicConfig fetches the public configuration for logs. ```APIDOC ## FetchPublicConfig ### Description Fetches the public configuration for logs. ### Signature ```go func FetchPublicConfig(ctx context.Context, opts PublicFetchOpts) ([]Log, error) ``` ``` -------------------------------- ### Default Witness Configuration Source: https://pkg.go.dev/github.com/transparency-dev/witness/omniwitness This variable holds the default configuration for the witness, embedded as YAML. ```go var ( // DefaultConfigLogs is the config for the witness used in the omniwitness. // Its schema is LogConfig //go:embed logs.yaml DefaultConfigLogs []byte ) ``` -------------------------------- ### NewFeedSource Source: https://pkg.go.dev/github.com/transparency-dev/witness/internal/feeder/tiles Creates and returns a new feeder.Source instance configured for a tlog-tiles log. This function is used to initialize the feeder with the necessary parameters. ```APIDOC ## func NewFeedSource ### Description NewFeedSource returns a populated feeder.NewFeedSource configured for a tlog-tiles log. ### Signature ```go func NewFeedSource(origin string, verifier note.Verifier, logURL string, c *http.Client) (feeder.Source, error) ``` ### Parameters * **origin** (string) - The origin of the log. * **verifier** (note.Verifier) - The verifier to use for validating notes. * **logURL** (string) - The URL of the tlog-tiles log. * **c** (*http.Client) - An HTTP client to use for communication. ### Returns * **feeder.Source** - A new feeder source instance. * **error** - An error if the source could not be created. ``` -------------------------------- ### Feeder NewSourceFunc Method Source: https://pkg.go.dev/github.com/transparency-dev/witness/omniwitness Returns a function that creates a new Source for the feeder. This is used internally for creating data sources. ```go func (f Feeder) NewSourceFunc() func(origin string, v note.Verifier, url string, c *http.Client) (feeder.Source, error) ``` -------------------------------- ### Obtain Bastion Backend ID Hash Source: https://pkg.go.dev/github.com/transparency-dev/witness/cmd/omniwitness This command derives the bastion backend ID hash from a private key file. This hash is required by the bastion host operator for provisioning. The omniwitness also prints this ID upon startup. ```bash $ openssl pkey -in ./my_bastion_private_key.pem -pubout -outform der | tail -c32 | sha256sum 02b2442688cd1728f5c25c8425d69a915daddcfa4eb28a809a6b144b0ba889f3 - ``` -------------------------------- ### Witness Update Method Source: https://pkg.go.dev/github.com/transparency-dev/witness/internal/witness Updates the latest checkpoint for a log if the new checkpoint is consistent with the current one. It returns the new checkpoint's signature and size, or an error indicating the reason for rejection. ```go func (w *Witness) Update(ctx context.Context, oldSize uint64, nextRaw []byte, cProof [][]byte) ([]byte, uint64, error) ``` -------------------------------- ### Generate GCP Witness Keys Source: https://pkg.go.dev/github.com/transparency-dev/witness/cmd/omniwitness_gcp Use this command to generate a new Ed25519 signing and verification key pair and store them directly in Secret Manager. Ensure WITNESS_SHORT_NAME and WITNESS_ORIGIN environment variables are set. ```bash export WITNESS_SHORT_NAME=example-witness export WITNESS_ORIGIN=" 0 then a partial tile will be fetched with the number of hashes. ### Signature func (c *SumDBClient) TileData(level, offset, partial int) ([]byte, error) ``` -------------------------------- ### ParsePublicWitnessConfig Source: https://pkg.go.dev/github.com/transparency-dev/witness/omniwitness ParsePublicWitnessConfig implements a parser for the public witness config format. ```APIDOC ## ParsePublicWitnessConfig ### Description Parses the public witness configuration from an io.Reader. ### Signature ```go func ParsePublicWitnessConfig(r io.Reader) ([]Log, error) ``` ``` -------------------------------- ### NewWitness Source: https://pkg.go.dev/github.com/transparency-dev/witness/client/http NewWitness returns a Witness accessed over http at the given URL using the client provided. ```APIDOC ## NewWitness ### Description Creates a new Witness client. ### Method `NewWitness` ### Parameters - `url` (*url.URL) - The URL of the witness. - `c` (*http.Client) - The HTTP client to use for requests. ### Returns - `Witness` - An instance of the Witness client. ``` -------------------------------- ### LogYAML Struct Definition Source: https://pkg.go.dev/github.com/transparency-dev/witness/omniwitness Represents the structure for log details stored in YAML format. This includes origin, public key, URL, and feeder information. ```go type LogYAML struct { Origin string `yaml:"Origin"` PublicKey string `yaml:"PublicKey"` URL string `yaml:"URL"` Feeder Feeder `yaml:"Feeder"` } ``` -------------------------------- ### InertMetricFactory Type - Witness Monitoring Source: https://pkg.go.dev/github.com/transparency-dev/witness/monitoring An empty struct used to create inert metrics, primarily for testing purposes. It implements the MetricFactory interface. ```go type InertMetricFactory struct{} ``` -------------------------------- ### Witness GetCheckpoint Method Source: https://pkg.go.dev/github.com/transparency-dev/witness/internal/witness Retrieves a checkpoint for a specified log origin that is consistent with other checkpoints signed by this witness. Returns a nil checkpoint if none is stored. ```go func (w *Witness) GetCheckpoint(ctx context.Context, origin string) ([]byte, error) ``` -------------------------------- ### SumDBClient.LatestCheckpoint Source: https://pkg.go.dev/github.com/transparency-dev/witness/internal/client Retrieves the most recent checkpoint from the SumDB log. ```APIDOC ## LatestCheckpoint ### Description Gets the freshest Checkpoint. ### Signature func (c *SumDBClient) LatestCheckpoint() (*Checkpoint, error) ``` -------------------------------- ### TestUpdate Function Signature Source: https://pkg.go.dev/github.com/transparency-dev/witness/internal/persistence/testonly This function signature is used for testing persistence implementations. It accepts a testing object and a factory function to create persistence instances. ```go func TestUpdate(t *testing.T, lspFactory func() (persistence.LogStatePersistence, func() error)) ``` -------------------------------- ### Feeder MarshalYAML Method Source: https://pkg.go.dev/github.com/transparency-dev/witness/omniwitness Serializes the Feeder enum to its string representation for YAML marshaling. ```go func (f Feeder) MarshalYAML() (any, error) ``` -------------------------------- ### GetMetricFactory Source: https://pkg.go.dev/github.com/transparency-dev/witness/monitoring Retrieves the singleton MetricFactory instance used throughout the application. ```APIDOC ## GetMetricFactory ### Description Returns the singleton MetricFactory for this application. Code should not call this during static initialization as the main program is unlikely to have configured the factory by this time. The recommended pattern is to call this in a `sync.Once` before initializing counters. ### Signature ```go func GetMetricFactory() MetricFactory ``` ### Returns * `MetricFactory`: The singleton MetricFactory instance. ``` -------------------------------- ### NewStaticLogConfig Source: https://pkg.go.dev/github.com/transparency-dev/witness/omniwitness NewStaticLogConfig creates a new LogConfig based on the provided YAML data. ```APIDOC ## NewStaticLogConfig ### Description Creates a new LogConfig from YAML data. ### Signature ```go func NewStaticLogConfig(yamlCfg []byte) (*staticLogConfig, error) ``` ``` -------------------------------- ### SetMetricFactory Source: https://pkg.go.dev/github.com/transparency-dev/witness/monitoring Sets a singleton instance of a MetricFactory. This function must be called, and only the first call will have any effect. ```APIDOC ## SetMetricFactory ### Description Sets a singleton instance of a MetricFactory that will be used throughout the application. Only the first call to this method will have any effect and it _must_ be called. ### Signature ```go func SetMetricFactory(imf MetricFactory) ``` ### Parameters * `imf` (MetricFactory) - The MetricFactory instance to set. ``` -------------------------------- ### UpdateFn Function Signature Source: https://pkg.go.dev/github.com/transparency-dev/witness/omniwitness Defines the signature for a function that updates a witness. It takes context, old size, new checkpoint data, and proof, returning updated data and size. ```go type UpdateFn func(ctx context.Context, oldSize uint64, newCP []byte, proof [][]byte) ([]byte, uint64, error) ``` -------------------------------- ### LogYAML Structure Source: https://pkg.go.dev/github.com/transparency-dev/witness/omniwitness The LogYAML structure represents the details of a log, typically used for configuration. ```APIDOC ## LogYAML Structure ### Description The `LogYAML` struct holds the configuration details for a specific log, including its origin, public key, URL, and associated feeder information. ### Fields - **Origin** (string, `yaml:"Origin"`) - The origin of the log. - **PublicKey** (string, `yaml:"PublicKey"`) - The public key associated with the log. - **URL** (string, `yaml:"URL"`) - The URL for the log. - **Feeder** (Feeder, `yaml:"Feeder"`) - The feeder configuration for this log. ``` -------------------------------- ### Witness Struct Definition Source: https://pkg.go.dev/github.com/transparency-dev/witness/omniwitness Represents a target witness for feeding, containing an update function and a name. ```go type Witness struct { Update UpdateFn Name string } ``` -------------------------------- ### Persistence Type Alias Source: https://pkg.go.dev/github.com/transparency-dev/witness/omniwitness An alias for persistence.LogStatePersistence, describing the required functionality for persisting log state. ```go type Persistence = persistence.LogStatePersistence ``` -------------------------------- ### InertMetricFactory Source: https://pkg.go.dev/github.com/transparency-dev/witness/monitoring A factory that creates inert (no-op) metrics, primarily used for testing purposes. ```APIDOC ## InertMetricFactory ### Description Creates inert metrics for testing. ### Type ```go type InertMetricFactory struct{} ``` ### Methods * `NewCounter(name, help string, labelNames ...string) Counter`: Creates a new inert Counter. ``` -------------------------------- ### MetricFactory.NewCounter Source: https://pkg.go.dev/github.com/transparency-dev/witness/monitoring/prometheus NewCounter creates a new Counter object backed by Prometheus. It takes a name, help text, and optional label names. ```APIDOC ## func (MetricFactory) NewCounter ### Description NewCounter creates a new Counter object backed by Prometheus. ### Signature ```go func (pmf MetricFactory) NewCounter(name, help string, labelNames ...string) monitoring.Counter ``` ### Parameters * `name` (string) - The name of the metric. * `help` (string) - The help text for the metric. * `labelNames` (...string) - Optional label names for the metric. ``` -------------------------------- ### NewFeedSource Source: https://pkg.go.dev/github.com/transparency-dev/witness/internal/feeder/rekor_v1 NewFeedSource returns a populated FeedSource struct configured for Rekor v1 logs. ```APIDOC ## func NewFeedSource ### Description NewFeedSource returns a populated FeedSource struct configured for Rekor v1 logs. ### Signature ```go func NewFeedSource(origin string, verifier note.Verifier, logURL string, c *http.Client) (feeder.Source, error) ``` ### Parameters - **origin** (string) - Description not available. - **verifier** (note.Verifier) - Description not available. - **logURL** (string) - Description not available. - **c** (*http.Client) - Description not available. ### Returns - **feeder.Source** - Description not available. - **error** - Description not available. ``` -------------------------------- ### RunFeeders Source: https://pkg.go.dev/github.com/transparency-dev/witness/omniwitness RunFeeders continually feeds checkpoints from logs to witnesses according to the provided config. This is a long-running function which will only return when the context is done. ```APIDOC ## RunFeeders ### Description Continuously feeds checkpoints from logs to witnesses. ### Signature ```go func RunFeeders(ctx context.Context, opts RunFeedOpts) error ``` ``` -------------------------------- ### SumDBClient.ParseCheckpointNote Source: https://pkg.go.dev/github.com/transparency-dev/witness/internal/client Parses raw checkpoint note data into a Checkpoint struct. ```APIDOC ## ParseCheckpointNote ### Description Parses a previously acquired raw checkpoint note data. ### Signature func (c *SumDBClient) ParseCheckpointNote(checkpoint []byte) (*Checkpoint, error) ``` -------------------------------- ### MetricFactory Interface Source: https://pkg.go.dev/github.com/transparency-dev/witness/monitoring Defines the interface for creating different types of metrics, specifically focusing on creating counters. ```APIDOC ## MetricFactory ### Description Allows the creation of different types of metric. ### Interface ```go type MetricFactory interface { NewCounter(name, help string, labelNames ...string) Counter } ``` ### Methods * `NewCounter(name, help string, labelNames ...string) Counter`: Creates a new Counter metric. ```