Add PruningPointBlueWork.

This commit is contained in:
stasatdaglabs
2021-09-05 13:42:23 +03:00
parent 1a664983a3
commit 48182f652a
6 changed files with 42 additions and 17 deletions

View File

@@ -527,7 +527,8 @@ func MsgPruningPointProofToDomainPruningPointProof(pruningPointProofMessage *Msg
headers[i] = BlockHeaderToDomainBlockHeader(header)
}
return &externalapi.PruningPointProof{
Headers: headers,
Headers: headers,
PruningPointBlueWork: pruningPointProofMessage.PruningPointBlueWork,
}
}
@@ -537,6 +538,7 @@ func DomainPruningPointProofToMsgPruningPointProof(pruningPointProof *externalap
headers[i] = DomainBlockHeaderToBlockHeader(header)
}
return &MsgPruningPointProof{
Headers: headers,
Headers: headers,
PruningPointBlueWork: pruningPointProof.PruningPointBlueWork,
}
}

View File

@@ -1,10 +1,13 @@
package appmessage
import "math/big"
// MsgPruningPointProof represents a kaspa PruningPointProof message
type MsgPruningPointProof struct {
baseMessage
Headers []*MsgBlockHeader
Headers []*MsgBlockHeader
PruningPointBlueWork *big.Int
}
// Command returns the protocol command string for the message
@@ -13,8 +16,9 @@ func (msg *MsgPruningPointProof) Command() MessageCommand {
}
// NewMsgPruningPointProof returns a new MsgPruningPointProof.
func NewMsgPruningPointProof(headers []*MsgBlockHeader) *MsgPruningPointProof {
func NewMsgPruningPointProof(headers []*MsgBlockHeader, pruningPointBlueWork *big.Int) *MsgPruningPointProof {
return &MsgPruningPointProof{
Headers: headers,
Headers: headers,
PruningPointBlueWork: pruningPointBlueWork,
}
}

View File

@@ -1,6 +1,9 @@
package externalapi
import "math/big"
// PruningPointProof is the data structure holding the pruning point proof
type PruningPointProof struct {
Headers []BlockHeader
Headers []BlockHeader
PruningPointBlueWork *big.Int
}

View File

@@ -2803,7 +2803,8 @@ type PruningPointProofMessage struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Headers []*BlockHeader `protobuf:"bytes,1,rep,name=headers,proto3" json:"headers,omitempty"`
Headers []*BlockHeader `protobuf:"bytes,1,rep,name=headers,proto3" json:"headers,omitempty"`
PruningPointBlueWork []byte `protobuf:"bytes,2,opt,name=pruningPointBlueWork,proto3" json:"pruningPointBlueWork,omitempty"`
}
func (x *PruningPointProofMessage) Reset() {
@@ -2845,6 +2846,13 @@ func (x *PruningPointProofMessage) GetHeaders() []*BlockHeader {
return nil
}
func (x *PruningPointProofMessage) GetPruningPointBlueWork() []byte {
if x != nil {
return x.PruningPointBlueWork
}
return nil
}
var File_p2p_proto protoreflect.FileDescriptor
var file_p2p_proto_rawDesc = []byte{
@@ -3181,14 +3189,18 @@ var file_p2p_proto_rawDesc = []byte{
0x61, 0x64, 0x65, 0x72, 0x52, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x22, 0x21, 0x0a,
0x1f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x50, 0x72, 0x75, 0x6e, 0x69, 0x6e, 0x67, 0x50,
0x6f, 0x69, 0x6e, 0x74, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
0x22, 0x4c, 0x0a, 0x18, 0x50, 0x72, 0x75, 0x6e, 0x69, 0x6e, 0x67, 0x50, 0x6f, 0x69, 0x6e, 0x74,
0x50, 0x72, 0x6f, 0x6f, 0x66, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x30, 0x0a, 0x07,
0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48,
0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x42, 0x26,
0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x61, 0x73,
0x70, 0x61, 0x6e, 0x65, 0x74, 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x2f, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x22, 0x80, 0x01, 0x0a, 0x18, 0x50, 0x72, 0x75, 0x6e, 0x69, 0x6e, 0x67, 0x50, 0x6f, 0x69, 0x6e,
0x74, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x30, 0x0a,
0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b,
0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12,
0x32, 0x0a, 0x14, 0x70, 0x72, 0x75, 0x6e, 0x69, 0x6e, 0x67, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x42,
0x6c, 0x75, 0x65, 0x57, 0x6f, 0x72, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x14, 0x70,
0x72, 0x75, 0x6e, 0x69, 0x6e, 0x67, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x42, 0x6c, 0x75, 0x65, 0x57,
0x6f, 0x72, 0x6b, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f,
0x6d, 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x6e, 0x65, 0x74, 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61,
0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x33,
}
var (

View File

@@ -255,4 +255,5 @@ message RequestPruningPointProofMessage {
message PruningPointProofMessage {
repeated BlockHeader headers = 1;
bytes pruningPointBlueWork = 2;
}

View File

@@ -3,6 +3,7 @@ package protowire
import (
"github.com/kaspanet/kaspad/app/appmessage"
"github.com/pkg/errors"
"math/big"
)
func (x *KaspadMessage_PruningPointProof) toAppMessage() (appmessage.Message, error) {
@@ -23,7 +24,8 @@ func (x *KaspadMessage_PruningPointProof) toAppMessage() (appmessage.Message, er
}
}
return &appmessage.MsgPruningPointProof{
Headers: blockHeaders,
Headers: blockHeaders,
PruningPointBlueWork: big.NewInt(0).SetBytes(x.PruningPointProof.PruningPointBlueWork),
}, nil
}
@@ -38,7 +40,8 @@ func (x *KaspadMessage_PruningPointProof) fromAppMessage(msgPruningPointProof *a
}
x.PruningPointProof = &PruningPointProofMessage{
Headers: blockHeaders,
Headers: blockHeaders,
PruningPointBlueWork: msgPruningPointProof.PruningPointBlueWork.Bytes(),
}
return nil
}