Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import changes from the filecoin branch #41

Merged
merged 1 commit into from
Sep 24, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions refmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ var cidAtlasEntry = atlas.BuildEntry(cid.Cid{}).
)).
Complete()

var bigIntAtlasEntry = atlas.BuildEntry(big.Int{}).Transform().
// BigIntAtlasEntry gives a reasonable default encoding for big.Int. It is not
// included in the entries by default.
var BigIntAtlasEntry = atlas.BuildEntry(big.Int{}).Transform().
TransformMarshal(atlas.MakeMarshalTransformFunc(
func(i big.Int) ([]byte, error) {
return i.Bytes(), nil
Expand All @@ -33,9 +35,10 @@ var bigIntAtlasEntry = atlas.BuildEntry(big.Int{}).Transform().
})).
Complete()

var cborAtlas atlas.Atlas
// CborAtlas is the refmt.Atlas used by the CBOR IPLD decoder/encoder.
var CborAtlas atlas.Atlas
var cborSortingMode = atlas.KeySortMode_RFC7049
var atlasEntries = []*atlas.AtlasEntry{cidAtlasEntry, bigIntAtlasEntry}
var atlasEntries = []*atlas.AtlasEntry{cidAtlasEntry}

var (
cloner encoding.PooledCloner
Expand All @@ -48,12 +51,12 @@ func init() {
}

func rebuildAtlas() {
cborAtlas = atlas.MustBuild(atlasEntries...).
WithMapMorphism(atlas.MapMorphism{atlas.KeySortMode_RFC7049})
CborAtlas = atlas.MustBuild(atlasEntries...).
WithMapMorphism(atlas.MapMorphism{KeySortMode: atlas.KeySortMode_RFC7049})

marshaller = encoding.NewPooledMarshaller(cborAtlas)
unmarshaller = encoding.NewPooledUnmarshaller(cborAtlas)
cloner = encoding.NewPooledCloner(cborAtlas)
marshaller = encoding.NewPooledMarshaller(CborAtlas)
unmarshaller = encoding.NewPooledUnmarshaller(CborAtlas)
cloner = encoding.NewPooledCloner(CborAtlas)
}

// RegisterCborType allows to register a custom cbor type
Expand Down