diff --git a/cmd/chron-cli/main.go b/cmd/chron-cli/main.go new file mode 100644 index 0000000..da29a2c --- /dev/null +++ b/cmd/chron-cli/main.go @@ -0,0 +1,4 @@ +package main + +func main() { +} diff --git a/core/errors.go b/core/errors.go new file mode 100644 index 0000000..9a8bc95 --- /dev/null +++ b/core/errors.go @@ -0,0 +1 @@ +package core diff --git a/core/interfaces.go b/core/interfaces.go new file mode 100644 index 0000000..39cd9e3 --- /dev/null +++ b/core/interfaces.go @@ -0,0 +1,25 @@ +package core + +import ( + "context" + "io" +) + +type EntryStore interface { + Append(ctx context.Context, entry Entry) (EntryID, error) + + Redact(ctx context.Context, entryID EntryID) error + + Get(ctx context.Context, entryID EntryID) (Entry, error) + + ScanForwards(ctx context.Context, entryID EntryID) ([]EntryID, error) + ScanBackwards(ctx context.Context, entryID EntryID) ([]EntryID, error) + + Head(ctx context.Context, ledgerID LedgerID) (EntryID, error) + IsEmpty(ctx context.Context, ledgerID LedgerID) bool +} + +type PayloadStore interface { + Put(ctx context.Context, reader io.Reader) (PayloadID, error) + Delete(ctx context.Context, payloadID PayloadID) error +} diff --git a/core/interfaces/id.go b/core/interfaces/id.go deleted file mode 100644 index e69de29..0000000 diff --git a/core/interfaces/ledger.go b/core/interfaces/ledger.go deleted file mode 100644 index e69de29..0000000 diff --git a/core/interfaces/payload.go b/core/interfaces/payload.go deleted file mode 100644 index e69de29..0000000 diff --git a/core/ledger.go b/core/ledger.go new file mode 100644 index 0000000..5ebbb29 --- /dev/null +++ b/core/ledger.go @@ -0,0 +1,12 @@ +package core + +type Ledger struct { + entryStore EntryStore + payloadStore PayloadStore + + LedgerID LedgerID +} + +func NewLedger(entryStore EntryStore, payloadStore PayloadStore) (*Ledger, error) { + panic("unimplemented") +} diff --git a/core/service.go b/core/service.go deleted file mode 100644 index e69de29..0000000 diff --git a/core/types.go b/core/types.go new file mode 100644 index 0000000..8eedce2 --- /dev/null +++ b/core/types.go @@ -0,0 +1,27 @@ +package core + +import ( + "time" +) + +type LedgerID [16]byte + +type EntryID [16]byte +type PayloadID [16]byte + +type Hash [32]byte + +type Entry struct { + EntryID EntryID + + LedgerID LedgerID + Seq uint64 + + Timestamp time.Time + + Nonce [16]byte + Commitment Hash + + PreviousHash Hash + EntryHash Hash +} diff --git a/core/types/artifact.go b/core/types/artifact.go deleted file mode 100644 index e69de29..0000000 diff --git a/core/types/cursor.go b/core/types/cursor.go deleted file mode 100644 index e69de29..0000000 diff --git a/core/types/errors.go b/core/types/errors.go deleted file mode 100644 index e69de29..0000000 diff --git a/core/types/ingest.go b/core/types/ingest.go deleted file mode 100644 index e69de29..0000000 diff --git a/core/types/range.go b/core/types/range.go deleted file mode 100644 index e69de29..0000000 diff --git a/go.mod b/go.mod index f8d42de..7e7fe7f 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,5 @@ module git.michelsen.id/chron go 1.25.5 + +require github.com/google/uuid v1.6.0 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..7790d7c --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=