Skip to content

Commit

Permalink
fix: use the new library to parse cid from builtin_actor_event (#1292)
Browse files Browse the repository at this point in the history
* Use another lib to parse cid: go-ipld-prime.
  • Loading branch information
Terryhung authored Apr 25, 2024
1 parent a6d7a4a commit f470e2b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ require (
github.com/hibiken/asynq v0.23.0
github.com/hibiken/asynq/x v0.0.0-20220413130846-5c723f597e01
github.com/ipfs/go-ipld-format v0.6.0
github.com/ipld/go-ipld-prime v0.21.0
github.com/jedib0t/go-pretty/v6 v6.2.7
github.com/libp2p/go-libp2p v0.33.2
github.com/multiformats/go-varint v0.0.7
Expand Down Expand Up @@ -209,7 +210,6 @@ require (
github.com/ipld/go-car/v2 v2.13.1 // indirect
github.com/ipld/go-codec-dagpb v1.6.0 // indirect
github.com/ipld/go-ipld-adl-hamt v0.0.0-20220616142416-9004dbd839e0 // indirect
github.com/ipld/go-ipld-prime v0.21.0 // indirect
github.com/ipld/go-ipld-selector-text-lite v0.0.1 // indirect
github.com/ipni/go-libipni v0.0.8 // indirect
github.com/ipni/index-provider v0.12.0 // indirect
Expand Down
6 changes: 5 additions & 1 deletion tasks/messages/builtinactorevent/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import (
"github.com/fxamacker/cbor/v2"
"github.com/ipfs/go-cid"
logging "github.com/ipfs/go-log/v2"
"github.com/ipld/go-ipld-prime"
"github.com/ipld/go-ipld-prime/codec/dagcbor"
"github.com/ipld/go-ipld-prime/node/bindnode"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
)
Expand Down Expand Up @@ -153,11 +156,12 @@ func cborValueDecode(key string, value []byte) interface{} {
}
return resultBIGINT
case CID:
err = cbor.Unmarshal(value, &resultCID)
nd, err := ipld.DecodeUsingPrototype(value, dagcbor.Decode, bindnode.Prototype((*cid.Cid)(nil), nil))
if err != nil {
log.Errorf("cbor.Unmarshal err: %v, key: %v, value: %v", err, key, value)
return nil
}
resultCID = *bindnode.Unwrap(nd).(*cid.Cid)
return resultCID
}

Expand Down

0 comments on commit f470e2b

Please sign in to comment.