Skip to content

Commit e3caac8

Browse files
authored
Use latest vindex code (#1345)
1 parent 964dde4 commit e3caac8

File tree

4 files changed

+87
-51
lines changed

4 files changed

+87
-51
lines changed

experimental/vindex/cmd/main.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,7 @@ func mapFnFromFlags() vindex.MapFn {
234234
}
235235

236236
func runWebServer(vi *vindex.VerifiableIndex, outLogDir string) {
237-
web := NewServer(func(h [sha256.Size]byte) ([]uint64, error) {
238-
idxes, size := vi.Lookup(h)
239-
if size == 0 {
240-
return nil, errors.New("index not populated")
241-
}
242-
return idxes, nil
243-
})
237+
web := NewServer(vi.Lookup)
244238

245239
olfs := http.FileServer(http.Dir(outLogDir))
246240
r := mux.NewRouter()

experimental/vindex/cmd/web.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package main
1616

1717
import (
18+
"context"
1819
"crypto/sha256"
1920
_ "embed"
2021
"encoding/hex"
@@ -27,14 +28,14 @@ import (
2728
"k8s.io/klog/v2"
2829
)
2930

30-
func NewServer(lookup func([sha256.Size]byte) ([]uint64, error)) Server {
31+
func NewServer(lookup func(context.Context, [sha256.Size]byte) (api.LookupResponse, error)) Server {
3132
return Server{
3233
lookup: lookup,
3334
}
3435
}
3536

3637
type Server struct {
37-
lookup func([sha256.Size]byte) ([]uint64, error)
38+
lookup func(context.Context, [sha256.Size]byte) (api.LookupResponse, error)
3839
}
3940

4041
// handleLookup handles GET requests for looking up map entries.
@@ -58,15 +59,13 @@ func (s Server) handleLookup(w http.ResponseWriter, r *http.Request) {
5859

5960
klog.V(2).Infof("Received hash from request: '%s'", h)
6061

61-
idxes, err := s.lookup([sha256.Size]byte(h))
62+
resp, err := s.lookup(r.Context(), [sha256.Size]byte(h))
6263
if err != nil {
6364
http.Error(w, fmt.Sprintf("lookup failed: %v", err), http.StatusInternalServerError)
6465
return
6566
}
6667
w.Header().Set("Content-Type", "application/json")
6768
w.WriteHeader(http.StatusOK)
68-
var resp api.LookupResponse
69-
resp.IndexValue = idxes
7069
if err := json.NewEncoder(w).Encode(resp); err != nil {
7170
klog.Warningf("failed to encode response: %v", err)
7271
}

go.mod

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require (
1717
github.com/mattn/go-sqlite3 v1.14.32
1818
github.com/perlin-network/life v0.0.0-20191203030451-05c0e0f7eaea
1919
github.com/transparency-dev/formats v0.0.0-20250723101439-be3b1008ec3a
20-
github.com/transparency-dev/incubator v0.0.0-20250813135444-78648dfe8041
20+
github.com/transparency-dev/incubator v0.0.0-20250904134322-c3f334a65cac
2121
github.com/transparency-dev/merkle v0.0.2
2222
github.com/transparency-dev/serverless-log v0.0.0-20230914155322-9b6f31f76f1f
2323
github.com/u-root/u-root v0.15.0
@@ -34,24 +34,24 @@ require (
3434
require (
3535
bitbucket.org/creachadair/shell v0.0.8 // indirect
3636
cel.dev/expr v0.24.0 // indirect
37-
cloud.google.com/go v0.121.2 // indirect
38-
cloud.google.com/go/auth v0.16.3 // indirect
37+
cloud.google.com/go v0.121.6 // indirect
38+
cloud.google.com/go/auth v0.16.5 // indirect
3939
cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect
40-
cloud.google.com/go/compute/metadata v0.7.0 // indirect
40+
cloud.google.com/go/compute/metadata v0.8.0 // indirect
4141
cloud.google.com/go/iam v1.5.2 // indirect
4242
cloud.google.com/go/monitoring v1.24.2 // indirect
4343
cloud.google.com/go/profiler v0.4.3 // indirect
44-
cloud.google.com/go/storage v1.55.0 // indirect
44+
cloud.google.com/go/storage v1.56.1 // indirect
4545
filippo.io/edwards25519 v1.1.0 // indirect
46-
filippo.io/torchwood v0.5.1-0.20250605130057-fa65d721a6ce // indirect
46+
filippo.io/torchwood v0.5.1-0.20250821141945-7cf4555d7644 // indirect
4747
github.com/DataDog/zstd v1.4.5 // indirect
4848
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.29.0 // indirect
4949
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.53.0 // indirect
5050
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.53.0 // indirect
5151
github.com/Microsoft/go-winio v0.6.2 // indirect
5252
github.com/avast/retry-go/v4 v4.6.1 // indirect
5353
github.com/beorn7/perks v1.0.1 // indirect
54-
github.com/cenkalti/backoff/v5 v5.0.2 // indirect
54+
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
5555
github.com/cespare/xxhash/v2 v2.3.0 // indirect
5656
github.com/cncf/xds/go v0.0.0-20250501225837-2ac532fd4443 // indirect
5757
github.com/cockroachdb/errors v1.11.3 // indirect
@@ -90,9 +90,11 @@ require (
9090
github.com/klauspost/compress v1.18.0 // indirect
9191
github.com/kr/pretty v0.3.1 // indirect
9292
github.com/kr/text v0.2.0 // indirect
93+
github.com/mattn/go-isatty v0.0.20 // indirect
9394
github.com/moby/docker-image-spec v1.3.1 // indirect
9495
github.com/moby/sys/atomicwriter v0.1.0 // indirect
9596
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
97+
github.com/ncruces/go-strftime v0.1.9 // indirect
9698
github.com/opencontainers/go-digest v1.0.0 // indirect
9799
github.com/opencontainers/image-spec v1.1.1 // indirect
98100
github.com/pierrec/lz4/v4 v4.1.22 // indirect
@@ -102,9 +104,10 @@ require (
102104
github.com/prometheus/client_model v0.6.1 // indirect
103105
github.com/prometheus/common v0.62.0 // indirect
104106
github.com/prometheus/procfs v0.15.1 // indirect
107+
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
105108
github.com/rogpeppe/go-internal v1.14.1 // indirect
106109
github.com/spiffe/go-spiffe/v2 v2.5.0 // indirect
107-
github.com/transparency-dev/tessera v1.0.0-rc1 // indirect
110+
github.com/transparency-dev/tessera v1.0.0-rc2 // indirect
108111
github.com/u-root/uio v0.0.0-20240224005618-d2acac8f3701 // indirect
109112
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
110113
github.com/zeebo/errs v1.4.0 // indirect
@@ -117,15 +120,20 @@ require (
117120
go.opentelemetry.io/otel/sdk v1.37.0 // indirect
118121
go.opentelemetry.io/otel/sdk/metric v1.37.0 // indirect
119122
go.opentelemetry.io/otel/trace v1.37.0 // indirect
120-
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect
121-
golang.org/x/net v0.42.0 // indirect
123+
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 // indirect
124+
golang.org/x/net v0.43.0 // indirect
122125
golang.org/x/sys v0.35.0 // indirect
123126
golang.org/x/text v0.28.0 // indirect
124127
golang.org/x/time v0.12.0 // indirect
125-
google.golang.org/api v0.243.0 // indirect
128+
google.golang.org/api v0.248.0 // indirect
126129
google.golang.org/appengine v1.6.8 // indirect
127130
google.golang.org/genproto v0.0.0-20250603155806-513f23925822 // indirect
128-
google.golang.org/genproto/googleapis/api v0.0.0-20250707201910-8d1bb00bc6a7 // indirect
129-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250715232539-7130f93afb79 // indirect
131+
google.golang.org/genproto/googleapis/api v0.0.0-20250818200422-3122310a409c // indirect
132+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250818200422-3122310a409c // indirect
130133
gotest.tools/v3 v3.5.1 // indirect
134+
modernc.org/libc v1.65.7 // indirect
135+
modernc.org/mathutil v1.7.1 // indirect
136+
modernc.org/memory v1.11.0 // indirect
137+
modernc.org/sqlite v1.37.1 // indirect
138+
zombiezen.com/go/sqlite v1.4.2 // indirect
131139
)

0 commit comments

Comments
 (0)