aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus@rgdd.se>2023-03-18 13:20:27 +0100
committerRasmus Dahlberg <rasmus@rgdd.se>2023-03-18 13:20:38 +0100
commitb8b8e05c833dfb4c4191c8c1391e02d07e0e744f (patch)
tree65dfc946a218e81f97a2a8f867f4ef9661d0e4de
parent15ffe76847c4c0383c4d0c0a35fb29d5031d093b (diff)
renaming files and moving around
-rw-r--r--cmd_assemble.go (renamed from assemble.go)0
-rw-r--r--cmd_collect.go (renamed from collect.go)33
-rw-r--r--cmd_snapshot.go (renamed from snapshot.go)0
-rw-r--r--utils_housekeep.go (renamed from house_keeping.go)0
-rw-r--r--utils_state.go42
5 files changed, 42 insertions, 33 deletions
diff --git a/assemble.go b/cmd_assemble.go
index 246ba6e..246ba6e 100644
--- a/assemble.go
+++ b/cmd_assemble.go
diff --git a/collect.go b/cmd_collect.go
index 3c548db..0254bb3 100644
--- a/collect.go
+++ b/cmd_collect.go
@@ -16,7 +16,6 @@ import (
"git.cs.kau.se/rasmoste/ct-sans/internal/chunk"
"git.cs.kau.se/rasmoste/ct-sans/internal/merkle"
"git.cs.kau.se/rasmoste/ct-sans/internal/x509"
- ct "github.com/google/certificate-transparency-go"
"github.com/google/certificate-transparency-go/client"
"github.com/google/certificate-transparency-go/jsonclient"
"github.com/google/certificate-transparency-go/scanner"
@@ -299,35 +298,3 @@ func persist(c *chunk.Chunk,
logger.Printf("DEBUG: %s: persisted [%d, %d]\n", desc, oldTH.TreeSize, newTH.TreeSize)
return false, nil
}
-
-type treeHead struct {
- TreeSize int64 `json:"tree_size"`
- RootHash [sha256.Size]byte `json:root_hash"`
-}
-
-func readState(opts options, logID []byte) (treeHead, error) {
- if _, err := os.Stat(fmt.Sprintf("%s/%x/%s", opts.logDirectory, logID, opts.stateFile)); err != nil {
- return treeHead{0, sha256.Sum256(nil)}, nil
- }
- b, err := os.ReadFile(fmt.Sprintf("%s/%x/%s", opts.logDirectory, logID, opts.stateFile))
- if err != nil {
- return treeHead{}, err
- }
- var th treeHead
- if err := json.Unmarshal(b, &th); err != nil {
- return treeHead{}, err
- }
- return th, nil
-}
-
-func readSnapshot(opts options, logID []byte) (ct.SignedTreeHead, error) {
- b, err := os.ReadFile(fmt.Sprintf("%s/%x/%s", opts.logDirectory, logID, opts.sthFile))
- if err != nil {
- return ct.SignedTreeHead{}, err
- }
- var sth ct.SignedTreeHead
- if err := json.Unmarshal(b, &sth); err != nil {
- return ct.SignedTreeHead{}, err
- }
- return sth, nil
-}
diff --git a/snapshot.go b/cmd_snapshot.go
index 5a9c50e..5a9c50e 100644
--- a/snapshot.go
+++ b/cmd_snapshot.go
diff --git a/house_keeping.go b/utils_housekeep.go
index 670a95b..670a95b 100644
--- a/house_keeping.go
+++ b/utils_housekeep.go
diff --git a/utils_state.go b/utils_state.go
new file mode 100644
index 0000000..2273c24
--- /dev/null
+++ b/utils_state.go
@@ -0,0 +1,42 @@
+package main
+
+import (
+ "crypto/sha256"
+ "encoding/json"
+ "fmt"
+ "os"
+
+ ct "github.com/google/certificate-transparency-go"
+)
+
+type treeHead struct {
+ TreeSize int64 `json:"tree_size"`
+ RootHash [sha256.Size]byte `json:root_hash"`
+}
+
+func readState(opts options, logID []byte) (treeHead, error) {
+ if _, err := os.Stat(fmt.Sprintf("%s/%x/%s", opts.logDirectory, logID, opts.stateFile)); err != nil {
+ return treeHead{0, sha256.Sum256(nil)}, nil
+ }
+ b, err := os.ReadFile(fmt.Sprintf("%s/%x/%s", opts.logDirectory, logID, opts.stateFile))
+ if err != nil {
+ return treeHead{}, err
+ }
+ var th treeHead
+ if err := json.Unmarshal(b, &th); err != nil {
+ return treeHead{}, err
+ }
+ return th, nil
+}
+
+func readSnapshot(opts options, logID []byte) (ct.SignedTreeHead, error) {
+ b, err := os.ReadFile(fmt.Sprintf("%s/%x/%s", opts.logDirectory, logID, opts.sthFile))
+ if err != nil {
+ return ct.SignedTreeHead{}, err
+ }
+ var sth ct.SignedTreeHead
+ if err := json.Unmarshal(b, &sth); err != nil {
+ return ct.SignedTreeHead{}, err
+ }
+ return sth, nil
+}