From 155ab77cffbe8d3fe0c0b5d23416dd32fbdb1cff Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Wed, 11 Oct 2023 13:56:12 +0200 Subject: refactor(tvix/nar-bridge): use mh.SHA2_256 As correctly mentioned in https://cl.tvl.fyi/c/depot/+/9652/comment/03b9b96e_bbb337fd/, we shouldn't be using these magic constants, but pull them from where they're defined. This already is a dependency of go-nix, and pkg/pathinfosvc/server.go, so no changes in go.mod. Change-Id: I0cc41ce040fcbddf4b6171417bc9b0de55af4991 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9653 Tested-by: BuildkiteCI Reviewed-by: Brian McGee --- tvix/nar-bridge/pkg/http/narinfo.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tvix/nar-bridge/pkg/http/narinfo.go') diff --git a/tvix/nar-bridge/pkg/http/narinfo.go b/tvix/nar-bridge/pkg/http/narinfo.go index 5d963c34f91d..c938baba6590 100644 --- a/tvix/nar-bridge/pkg/http/narinfo.go +++ b/tvix/nar-bridge/pkg/http/narinfo.go @@ -4,7 +4,9 @@ import ( "fmt" storev1pb "code.tvl.fyi/tvix/store/protos" + mh "github.com/multiformats/go-multihash/core" nixhash "github.com/nix-community/go-nix/pkg/hash" + "github.com/nix-community/go-nix/pkg/narinfo" "github.com/nix-community/go-nix/pkg/narinfo/signature" "github.com/nix-community/go-nix/pkg/nixbase32" @@ -30,7 +32,7 @@ func ToNixNarInfo(p *storev1pb.PathInfo) (*narinfo.NarInfo, error) { // produce nixhash for the narsha256. narHash, err := nixhash.FromHashTypeAndDigest( - 0x12, // SHA2_256 + mh.SHA2_256, p.GetNarinfo().GetNarSha256(), ) if err != nil { -- cgit 1.4.1