diff --git a/go.mod b/go.mod index 00e2521..0366bf7 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/gammazero/radixtree v0.3.1 github.com/ipfs/go-cid v0.4.1 github.com/ipfs/go-log/v2 v2.5.1 - github.com/ipni/go-libipni v0.5.15 + github.com/ipni/go-libipni v0.5.16 github.com/libp2p/go-libp2p v0.33.2 github.com/mr-tron/base58 v1.2.0 github.com/multiformats/go-multihash v0.2.3 diff --git a/go.sum b/go.sum index 2ffb0ba..2d372ae 100644 --- a/go.sum +++ b/go.sum @@ -80,8 +80,8 @@ github.com/ipfs/go-log/v2 v2.5.1 h1:1XdUzF7048prq4aBjDQQ4SL5RxftpRGdXhNRwKSAlcY= github.com/ipfs/go-log/v2 v2.5.1/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI= github.com/ipld/go-ipld-prime v0.21.0 h1:n4JmcpOlPDIxBcY037SVfpd1G+Sj1nKZah0m6QH9C2E= github.com/ipld/go-ipld-prime v0.21.0/go.mod h1:3RLqy//ERg/y5oShXXdx5YIp50cFGOanyMctpPjsvxQ= -github.com/ipni/go-libipni v0.5.15 h1:fpiCapQTmop5vD61aZlyHwKxDTmi9cHh4cTYFtPYDeg= -github.com/ipni/go-libipni v0.5.15/go.mod h1:SiibaNEFWlEnuNewo/hMVI/517b9a6p7C6qpigG8UT8= +github.com/ipni/go-libipni v0.5.16 h1:icM/MLlXHVnAilyT5N6b0jYveWkimir55OZFIFehDXg= +github.com/ipni/go-libipni v0.5.16/go.mod h1:BMbHRRcCvvIBI311bnE4XifksV2iA8QOCfST4u+8lbs= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.17.6 h1:60eq2E/jlfwQXtvZEeBUYADs+BwKBWURIY+Gj2eRGjI= diff --git a/store/dhstore/dhstore.go b/store/dhstore/dhstore.go index ddde34e..5b5a702 100644 --- a/store/dhstore/dhstore.go +++ b/store/dhstore/dhstore.go @@ -115,8 +115,7 @@ func (s *dhStore) Put(value indexer.Value, mhs ...multihash.Multihash) error { start := time.Now() ctx := context.Background() - err = s.sendDHMetadata(ctx, metaReq) - if err != nil { + if err = s.sendDHMetadata(ctx, metaReq); err != nil { return err } @@ -130,23 +129,19 @@ func (s *dhStore) Put(value indexer.Value, mhs ...multihash.Multihash) error { } merges := make([]client.Index, 0, size) for _, mh := range mhs { - dm, err := multihash.Decode(mh) - if err != nil { - return err + if _, err = multihash.Decode(mh); err != nil { + log.Errorw("Failed to decode multihash, skipping", "err", err) + continue } - if dm.Code == multihash.DBL_SHA2_256 { - return errors.New("put double-hashed index not supported") - } - merge, err := makeDHMerge(mh, valueKey) if err != nil { - return err + log.Errorw("Failed to create dhmerge for multihash, skipping", "err", err) + continue } merges = append(merges, merge) if len(merges) == cap(merges) { - err = s.sendDHMergeIndexRequest(ctx, merges) - if err != nil { + if err = s.sendDHMergeIndexRequest(ctx, merges); err != nil { return err } merges = merges[:0] @@ -155,8 +150,7 @@ func (s *dhStore) Put(value indexer.Value, mhs ...multihash.Multihash) error { // Send remaining merge requests. if len(merges) != 0 { - err = s.sendDHMergeIndexRequest(ctx, merges) - if err != nil { + if err = s.sendDHMergeIndexRequest(ctx, merges); err != nil { return err } } @@ -297,11 +291,6 @@ func (s *dhStore) Stats() (*indexer.Stats, error) { } func makeDHMerge(mh multihash.Multihash, valueKey []byte) (client.Index, error) { - mh2, err := dhash.SecondMultihash(mh) - if err != nil { - return client.Index{}, err - } - // Encrypt value key with original multihash. encValueKey, err := dhash.EncryptValueKey(valueKey, mh) if err != nil { @@ -309,7 +298,7 @@ func makeDHMerge(mh multihash.Multihash, valueKey []byte) (client.Index, error) } return client.Index{ - Key: mh2, + Key: dhash.SecondMultihash(mh), Value: encValueKey, }, nil }