Merge pull request #156 from filecoin-project/fix/mining-regression
Fix mining after typecode changes to signatures
This commit is contained in:
commit
3e7017e7c1
@ -47,7 +47,7 @@ func MinerCreateBlock(ctx context.Context, cs *store.ChainStore, miner address.A
|
|||||||
var blsMsgCids, secpkMsgCids []cid.Cid
|
var blsMsgCids, secpkMsgCids []cid.Cid
|
||||||
var blsSigs []types.Signature
|
var blsSigs []types.Signature
|
||||||
for _, msg := range msgs {
|
for _, msg := range msgs {
|
||||||
if msg.Signature.TypeCode() == 2 {
|
if msg.Signature.TypeCode() == types.IKTBLS {
|
||||||
blsSigs = append(blsSigs, msg.Signature)
|
blsSigs = append(blsSigs, msg.Signature)
|
||||||
blsMessages = append(blsMessages, &msg.Message)
|
blsMessages = append(blsMessages, &msg.Message)
|
||||||
|
|
||||||
|
@ -22,6 +22,11 @@ const (
|
|||||||
KTBLS = "bls"
|
KTBLS = "bls"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
IKTSecp256k1 = iota
|
||||||
|
IKTBLS
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
cbor.RegisterCborType(atlas.BuildEntry(Signature{}).Transform().
|
cbor.RegisterCborType(atlas.BuildEntry(Signature{}).Transform().
|
||||||
TransformMarshal(atlas.MakeMarshalTransformFunc(
|
TransformMarshal(atlas.MakeMarshalTransformFunc(
|
||||||
@ -49,9 +54,9 @@ func SignatureFromBytes(x []byte) (Signature, error) {
|
|||||||
}
|
}
|
||||||
var ts string
|
var ts string
|
||||||
switch val {
|
switch val {
|
||||||
case 0:
|
case IKTSecp256k1:
|
||||||
ts = KTSecp256k1
|
ts = KTSecp256k1
|
||||||
case 1:
|
case IKTBLS:
|
||||||
ts = KTBLS
|
ts = KTBLS
|
||||||
default:
|
default:
|
||||||
return Signature{}, fmt.Errorf("unsupported signature type: %d", val)
|
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 {
|
func (s *Signature) TypeCode() int {
|
||||||
switch s.Type {
|
switch s.Type {
|
||||||
case KTSecp256k1:
|
case KTSecp256k1:
|
||||||
return 0
|
return IKTSecp256k1
|
||||||
case KTBLS:
|
case KTBLS:
|
||||||
return 1
|
return IKTBLS
|
||||||
default:
|
default:
|
||||||
panic("unsupported signature type")
|
panic("unsupported signature type")
|
||||||
}
|
}
|
||||||
@ -157,9 +162,9 @@ func (s *Signature) UnmarshalCBOR(br cbg.ByteReader) error {
|
|||||||
switch buf[0] {
|
switch buf[0] {
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("invalid signature type in cbor input: %d", buf[0])
|
return fmt.Errorf("invalid signature type in cbor input: %d", buf[0])
|
||||||
case 0:
|
case IKTSecp256k1:
|
||||||
s.Type = KTSecp256k1
|
s.Type = KTSecp256k1
|
||||||
case 1:
|
case IKTBLS:
|
||||||
s.Type = KTBLS
|
s.Type = KTBLS
|
||||||
}
|
}
|
||||||
s.Data = buf[1:]
|
s.Data = buf[1:]
|
||||||
|
Loading…
Reference in New Issue
Block a user