Documentation ¶
Index ¶
- Constants
- type API
- type CheckSummer
- type Config
- type Repo
- func (r *Repo) ChecksumExists(hash string) (bool, error)
- func (r *Repo) Close() error
- func (r *Repo) FindGaps(start, stop int) ([][2]uint, error)
- func (r *Repo) FindNextChecksum() (uint, error)
- func (r *Repo) GetChecksum(start, stop uint) (string, error)
- func (r *Repo) Interval() uint
- func (r *Repo) PublishChecksum(start, stop uint, hash string) error
- type Service
Constants ¶
const ( LOG_FILE = "LOG_FILE" LOG_LEVEL = "LOG_LEVEL" SERVER_PORT = "SERVER_PORT" SUPPORTS_SERVER = "SUPPORTS_SERVER" CHECKSUM_DB_DIRECTORY = "CHECKSUM_DB_DIRECTORY" MSG_INDEX_DB_DIRECTORY = "MSG_INDEX_DB_DIRECTORY" SUPPORTS_CHECKSUMMING = "SUPPORTS_CHECKSUMMING" CHECKSUM_CHUNK_SIZE = "CHECKSUM_CHUNK_SIZE" )
Env variables
const ( LOG_FILE_TOML = "log.file" LOG_LEVEL_TOML = "log.level" SERVER_PORT_TOML = "server.port" SUPPORTS_SERVER_TOML = "server.on" CHECKSUM_DB_DIRECTORY_TOML = "database.checksumPath" MSG_INDEX_DB_DIRECTORY_TOML = "database.msgIndexPath" SUPPORTS_CHECKSUMMING_TOML = "checksum.on" CHECKSUM_CHUNK_SIZE_TOML = "checksum.chunkSize" )
TOML bindings
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API is kind of an unnecessary abstraction since this only wraps a single backing struct, but it will make it easier to extend the API in the future (add and use new backing components)
func (API) ChecksumExists ¶
ChecksumExists returns true if the given checksum is published in the backing checksum repository
func (API) GetChecksum ¶
func (a API) GetChecksum(rng types.GetChecksumRequest, res *string) error
GetChecksum returns the checksum for the given start and stop values
type CheckSummer ¶
type CheckSummer struct {
// contains filtered or unexported fields
}
func NewChecksummer ¶
func NewChecksummer(srcDir string) (*CheckSummer, error)
NewChecksummer creates a new checksumming object
func (*CheckSummer) CheckRangeIsPopulated ¶
func (cs *CheckSummer) CheckRangeIsPopulated(start, stop uint) (bool, error)
CheckRangeIsPopulated checks if the message index table is populated for the given range
type Config ¶
type Config struct { // support checksumming Checksum bool // support API Serve bool // Port to expose API on ServerPort string // Directory with the source msgindex.db sqlite file SrcDBDir string // Directory with/for the checksums.db sqlite file RepoDBDir string // Chunk range size for checksumming ChecksumChunkSize uint // Whether to check for gaps in the checksum repo at initialization if the repo already exists CheckForGaps uint }
Config holds the configuration params for the attestation service
type Repo ¶
type Repo struct {
// contains filtered or unexported fields
}
func (*Repo) ChecksumExists ¶
ChecksumExists checks if the given checksum hash exists in the repository
func (*Repo) FindGaps ¶
FindGaps finds gaps in the checksums table between start and stop (inclusive)
func (*Repo) FindNextChecksum ¶
FindNextChecksum finds the `start` epoch for the next checksum that needs to be published
func (*Repo) GetChecksum ¶
GetChecksum gets the checksum for the given range
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the attestation service top-level object
func NewService ¶
func NewService(cs types.Checksummer, repo types.ChecksumRepository, start, chunkSize uint) (*Service, error)
NewService creates a new attestation service it accepts pre-initialized checksummer and checksum repository objects useful for testing with mocks that satisfy these interfaces
func NewServiceFromConfig ¶
NewServiceFromConfig creates a new attestation service from a config object
func (*Service) Register ¶
Register registers the internal API with the provided registration function (e.g. rpc.Register)
func (*Service) Serve ¶
Serve starts an empty loop that waits for a quit signal used to isolate the RPC server loop from the checksum processing loop e.g. can start this with only a checksum repository to serve the RPC API, with no active background checksummer process or can use a cancel ctx passed into `Start` to stop the checksumming processes without stopping this loop TODO: wire the API into here such that 1. users can request a (missing) checksum be calculated 2. if a request to GetChecksum is made for a range that is not yet checksummed, the checksumming process can be triggered (if the range is found to be complete in local msgindex.db)