From 78bfcce90782d3c62edf0eb52e8f874517531ceb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 26 Aug 2019 10:46:01 +0200 Subject: [PATCH] Fix mining after typecode changes to signatures --- chain/gen/mining.go | 2 +- chain/types/signature.go | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/chain/gen/mining.go b/chain/gen/mining.go index cc7ee5e9b..fc407be08 100644 --- a/chain/gen/mining.go +++ b/chain/gen/mining.go @@ -47,7 +47,7 @@ func MinerCreateBlock(ctx context.Context, cs *store.ChainStore, miner address.A var blsMsgCids, secpkMsgCids []cid.Cid var blsSigs []types.Signature for _, msg := range msgs { - if msg.Signature.TypeCode() == 2 { + if msg.Signature.TypeCode() == types.IKTBLS { blsSigs = append(blsSigs, msg.Signature) blsMessages = append(blsMessages, &msg.Message) diff --git a/chain/types/signature.go b/chain/types/signature.go index 306e6475a..b0a1e084c 100644 --- a/chain/types/signature.go +++ b/chain/types/signature.go @@ -22,6 +22,11 @@ const ( KTBLS = "bls" ) +const ( + IKTSecp256k1 = iota + IKTBLS +) + func init() { cbor.RegisterCborType(atlas.BuildEntry(Signature{}).Transform(). TransformMarshal(atlas.MakeMarshalTransformFunc( @@ -49,9 +54,9 @@ func SignatureFromBytes(x []byte) (Signature, error) { } var ts string switch val { - case 0: + case IKTSecp256k1: ts = KTSecp256k1 - case 1: + case IKTBLS: ts = KTBLS default: return Signature{}, fmt.Errorf("unsupported signature type: %d", val) @@ -109,9 +114,9 @@ func (s *Signature) Verify(addr address.Address, msg []byte) error { func (s *Signature) TypeCode() int { switch s.Type { case KTSecp256k1: - return 0 + return IKTSecp256k1 case KTBLS: - return 1 + return IKTBLS default: panic("unsupported signature type") } @@ -157,9 +162,9 @@ func (s *Signature) UnmarshalCBOR(br cbg.ByteReader) error { switch buf[0] { default: return fmt.Errorf("invalid signature type in cbor input: %d", buf[0]) - case 0: + case IKTSecp256k1: s.Type = KTSecp256k1 - case 1: + case IKTBLS: s.Type = KTBLS } s.Data = buf[1:]