aboutsummaryrefslogtreecommitdiff
path: root/cmd/sigsum-log-primary/main.go
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordberg.se>2022-07-19 17:11:47 +0200
committerLinus Nordberg <linus@nordberg.se>2022-07-19 17:11:47 +0200
commit387914dfcfda0f84f13b4d49f5b2371867cace46 (patch)
tree28ff7eeff748cf24b04ed967e93f6c2cc6b752bb /cmd/sigsum-log-primary/main.go
parentc8180107a6c281320fff2675abd7943cf5acafe2 (diff)
store and restore of latest published STH
Diffstat (limited to 'cmd/sigsum-log-primary/main.go')
-rw-r--r--cmd/sigsum-log-primary/main.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/cmd/sigsum-log-primary/main.go b/cmd/sigsum-log-primary/main.go
index f64643a..539dd52 100644
--- a/cmd/sigsum-log-primary/main.go
+++ b/cmd/sigsum-log-primary/main.go
@@ -47,6 +47,7 @@ var (
logColor = flag.Bool("log-color", false, "colored logging output (Default: false)")
secondaryURL = flag.String("secondary-url", "", "secondary node endpoint for fetching latest replicated tree head")
secondaryPubkey = flag.String("secondary-pubkey", "", "hex-encoded Ed25519 public key for secondary node")
+ sthStorePath = flag.String("sth-path", "/var/lib/sigsum-log/sth", "path to file where latest published STH is being stored")
gitCommit = "unknown"
)
@@ -66,7 +67,12 @@ func main() {
defer cancel()
log.Debug("configuring log-go-primary")
- node, err := setupPrimaryFromFlags()
+ sthFile, err := os.OpenFile(*sthStorePath, os.O_RDWR|os.O_CREATE, 0644)
+ if err != nil {
+ log.Fatal("opening STH file: %v", err)
+ }
+ defer sthFile.Close()
+ node, err := setupPrimaryFromFlags(sthFile)
if err != nil {
log.Fatal("setup primary: %v", err)
}
@@ -117,7 +123,7 @@ func main() {
}
// setupPrimaryFromFlags() sets up a new sigsum primary node from flags.
-func setupPrimaryFromFlags() (*primary.Primary, error) {
+func setupPrimaryFromFlags(sthFile *os.File) (*primary.Primary, error) {
var p primary.Primary
var err error
@@ -167,7 +173,7 @@ func setupPrimaryFromFlags() (*primary.Primary, error) {
}
// Setup state manager.
- p.Stateman, err = state.NewStateManagerSingle(p.TrillianClient, p.Signer, p.Config.Interval, p.Config.Deadline, p.Secondary)
+ p.Stateman, err = state.NewStateManagerSingle(p.TrillianClient, p.Signer, p.Config.Interval, p.Config.Deadline, p.Secondary, sthFile)
if err != nil {
return nil, fmt.Errorf("NewStateManagerSingle: %v", err)
}