Skip to content

Commit

Permalink
Only define decode method in legacy codecs (#2241)
Browse files Browse the repository at this point in the history
Follow up to #2038.
  • Loading branch information
pm47 authored Apr 28, 2022
1 parent f099409 commit 56c9e06
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ private[channel] object ChannelCodecs0 {
("chaincode" | bytes32) ::
("depth" | uint16) ::
("path" | keyPathCodec) ::
("parent" | int64)).xmap(
{ case a :: b :: c :: d :: e :: HNil => ExtendedPrivateKey(a, b, c, d, e) },
{ exp: ExtendedPrivateKey => exp.secretkeybytes :: exp.chaincode :: exp.depth :: exp.path :: exp.parent :: HNil }
).decodeOnly
("parent" | int64))
.map { case a :: b :: c :: d :: e :: HNil => ExtendedPrivateKey(a, b, c, d, e) }
.decodeOnly

val channelVersionCodec: Codec[ChannelTypes0.ChannelVersion] = discriminatorWithDefault[ChannelTypes0.ChannelVersion](
discriminator = discriminated[ChannelTypes0.ChannelVersion].by(byte)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ private[channel] object ChannelCodecs1 {
("chaincode" | bytes32) ::
("depth" | uint16) ::
("path" | keyPathCodec) ::
("parent" | int64)).xmap(
{ case a :: b :: c :: d :: e :: HNil => ExtendedPrivateKey(a, b, c, d, e) },
{ exp: ExtendedPrivateKey => exp.secretkeybytes :: exp.chaincode :: exp.depth :: exp.path :: exp.parent :: HNil }
)
("parent" | int64))
.map { case a :: b :: c :: d :: e :: HNil => ExtendedPrivateKey(a, b, c, d, e) }
.decodeOnly

val channelVersionCodec: Codec[ChannelTypes0.ChannelVersion] = bits(ChannelTypes0.ChannelVersion.LENGTH_BITS).as[ChannelTypes0.ChannelVersion]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ private[channel] object ChannelCodecs2 {
("chaincode" | bytes32) ::
("depth" | uint16) ::
("path" | keyPathCodec) ::
("parent" | int64)).xmap(
{ case a :: b :: c :: d :: e :: HNil => ExtendedPrivateKey(a, b, c, d, e) },
{ exp: ExtendedPrivateKey => exp.secretkeybytes :: exp.chaincode :: exp.depth :: exp.path :: exp.parent :: HNil }
)
("parent" | int64))
.map { case a :: b :: c :: d :: e :: HNil => ExtendedPrivateKey(a, b, c, d, e) }
.decodeOnly

val channelVersionCodec: Codec[ChannelTypes0.ChannelVersion] = bits(ChannelTypes0.ChannelVersion.LENGTH_BITS).as[ChannelTypes0.ChannelVersion]

Expand Down

0 comments on commit 56c9e06

Please sign in to comment.