-
Notifications
You must be signed in to change notification settings - Fork 702
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
Cleanup codec usage #2563
Cleanup codec usage #2563
Changes from 8 commits
a322a36
0d71dc9
207610f
fb75170
196d1f2
b0cd447
d16862a
ed5f962
cb754fd
9f86b13
c212691
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
package encdb | ||
|
||
import ( | ||
"github.com/ava-labs/avalanchego/codec" | ||
"github.com/ava-labs/avalanchego/codec/linearcodec" | ||
) | ||
|
||
const CodecVersion = 0 | ||
|
||
var Codec codec.Manager | ||
|
||
func init() { | ||
lc := linearcodec.NewDefault() | ||
Codec = codec.NewDefaultManager() | ||
|
||
if err := Codec.RegisterCodec(CodecVersion, lc); err != nil { | ||
panic(err) | ||
} | ||
} | ||
Comment on lines
+11
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was no reason we created a new codec for each |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
package indexer | ||
|
||
import ( | ||
"math" | ||
|
||
"github.com/ava-labs/avalanchego/codec" | ||
"github.com/ava-labs/avalanchego/codec/linearcodec" | ||
) | ||
|
||
const CodecVersion = 0 | ||
|
||
var Codec codec.Manager | ||
|
||
func init() { | ||
lc := linearcodec.NewCustomMaxLength(math.MaxUint32) | ||
Codec = codec.NewManager(math.MaxInt) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was no reason to have a complex calculated maximum length here. |
||
|
||
if err := Codec.RegisterCodec(CodecVersion, lc); err != nil { | ||
panic(err) | ||
} | ||
} | ||
Comment on lines
+13
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was no reason we created a new codec for each indexer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codec
is much easier to read thanc
and this allows easier usage of the format.