carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package host
2
3import (
4 "context"
5 "crypto/ed25519"
6 "crypto/rand"
7 "encoding/hex"
8 "time"
9
10 "github.com/carlosframework/platform/internal/hostactors"
11 "github.com/carlosframework/platform/internal/hostops"
12 "github.com/carlosframework/platform/internal/hostwrite"
13 "github.com/carlosframework/platform/internal/release"
14)
15
16func newClaimBackfill(writes hostwrite.Config, s release.Store, pub ed25519.PublicKey, bucket string) func(context.Context) error {
17 if !writes.Enabled {
18 return func(context.Context) error { return nil }
19 }
20 if s == nil || len(pub) == 0 || bucket == "" {
21 return func(context.Context) error { return hostops.ErrContract }
22 }
23 d := hostactors.Directory{Store: s, PublicKey: pub, Bucket: bucket}
24 c := hostops.NewBackfillController(s, d, time.Now, func() string {
25 var b [16]byte
26 if _, err := rand.Read(b[:]); err != nil {
27 return ""
28 }
29 return hex.EncodeToString(b[:])
30 })
31 return c.ReconcileClaims
32}
33