Merge pull request #40 from str4d/prevhash

Add PrevHash field to CompactBlocks
This commit is contained in:
str4d
2019-05-13 09:56:45 +01:00
committed by GitHub
4 changed files with 51 additions and 40 deletions

View File

@@ -91,6 +91,7 @@ func (b *block) ToCompact() *walletrpc.CompactBlock {
//TODO ProtoVersion: 1, //TODO ProtoVersion: 1,
Height: uint64(b.GetHeight()), Height: uint64(b.GetHeight()),
Hash: b.GetEncodableHash(), Hash: b.GetEncodableHash(),
PrevHash: b.hdr.HashPrevBlock,
Time: b.hdr.Time, Time: b.hdr.Time,
} }

File diff suppressed because one or more lines are too long

View File

@@ -26,9 +26,10 @@ type CompactBlock struct {
ProtoVersion uint32 `protobuf:"varint,1,opt,name=protoVersion,proto3" json:"protoVersion,omitempty"` ProtoVersion uint32 `protobuf:"varint,1,opt,name=protoVersion,proto3" json:"protoVersion,omitempty"`
Height uint64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` Height uint64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"`
Hash []byte `protobuf:"bytes,3,opt,name=hash,proto3" json:"hash,omitempty"` Hash []byte `protobuf:"bytes,3,opt,name=hash,proto3" json:"hash,omitempty"`
Time uint32 `protobuf:"varint,4,opt,name=time,proto3" json:"time,omitempty"` PrevHash []byte `protobuf:"bytes,4,opt,name=prevHash,proto3" json:"prevHash,omitempty"`
Header []byte `protobuf:"bytes,5,opt,name=header,proto3" json:"header,omitempty"` Time uint32 `protobuf:"varint,5,opt,name=time,proto3" json:"time,omitempty"`
Vtx []*CompactTx `protobuf:"bytes,6,rep,name=vtx,proto3" json:"vtx,omitempty"` Header []byte `protobuf:"bytes,6,opt,name=header,proto3" json:"header,omitempty"`
Vtx []*CompactTx `protobuf:"bytes,7,rep,name=vtx,proto3" json:"vtx,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -38,7 +39,7 @@ func (m *CompactBlock) Reset() { *m = CompactBlock{} }
func (m *CompactBlock) String() string { return proto.CompactTextString(m) } func (m *CompactBlock) String() string { return proto.CompactTextString(m) }
func (*CompactBlock) ProtoMessage() {} func (*CompactBlock) ProtoMessage() {}
func (*CompactBlock) Descriptor() ([]byte, []int) { func (*CompactBlock) Descriptor() ([]byte, []int) {
return fileDescriptor_compact_formats_e98cba77ef7a6fd2, []int{0} return fileDescriptor_compact_formats_a15b2a7f016abebd, []int{0}
} }
func (m *CompactBlock) XXX_Unmarshal(b []byte) error { func (m *CompactBlock) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CompactBlock.Unmarshal(m, b) return xxx_messageInfo_CompactBlock.Unmarshal(m, b)
@@ -79,6 +80,13 @@ func (m *CompactBlock) GetHash() []byte {
return nil return nil
} }
func (m *CompactBlock) GetPrevHash() []byte {
if m != nil {
return m.PrevHash
}
return nil
}
func (m *CompactBlock) GetTime() uint32 { func (m *CompactBlock) GetTime() uint32 {
if m != nil { if m != nil {
return m.Time return m.Time
@@ -123,7 +131,7 @@ func (m *CompactTx) Reset() { *m = CompactTx{} }
func (m *CompactTx) String() string { return proto.CompactTextString(m) } func (m *CompactTx) String() string { return proto.CompactTextString(m) }
func (*CompactTx) ProtoMessage() {} func (*CompactTx) ProtoMessage() {}
func (*CompactTx) Descriptor() ([]byte, []int) { func (*CompactTx) Descriptor() ([]byte, []int) {
return fileDescriptor_compact_formats_e98cba77ef7a6fd2, []int{1} return fileDescriptor_compact_formats_a15b2a7f016abebd, []int{1}
} }
func (m *CompactTx) XXX_Unmarshal(b []byte) error { func (m *CompactTx) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CompactTx.Unmarshal(m, b) return xxx_messageInfo_CompactTx.Unmarshal(m, b)
@@ -189,7 +197,7 @@ func (m *CompactSpend) Reset() { *m = CompactSpend{} }
func (m *CompactSpend) String() string { return proto.CompactTextString(m) } func (m *CompactSpend) String() string { return proto.CompactTextString(m) }
func (*CompactSpend) ProtoMessage() {} func (*CompactSpend) ProtoMessage() {}
func (*CompactSpend) Descriptor() ([]byte, []int) { func (*CompactSpend) Descriptor() ([]byte, []int) {
return fileDescriptor_compact_formats_e98cba77ef7a6fd2, []int{2} return fileDescriptor_compact_formats_a15b2a7f016abebd, []int{2}
} }
func (m *CompactSpend) XXX_Unmarshal(b []byte) error { func (m *CompactSpend) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CompactSpend.Unmarshal(m, b) return xxx_messageInfo_CompactSpend.Unmarshal(m, b)
@@ -229,7 +237,7 @@ func (m *CompactOutput) Reset() { *m = CompactOutput{} }
func (m *CompactOutput) String() string { return proto.CompactTextString(m) } func (m *CompactOutput) String() string { return proto.CompactTextString(m) }
func (*CompactOutput) ProtoMessage() {} func (*CompactOutput) ProtoMessage() {}
func (*CompactOutput) Descriptor() ([]byte, []int) { func (*CompactOutput) Descriptor() ([]byte, []int) {
return fileDescriptor_compact_formats_e98cba77ef7a6fd2, []int{3} return fileDescriptor_compact_formats_a15b2a7f016abebd, []int{3}
} }
func (m *CompactOutput) XXX_Unmarshal(b []byte) error { func (m *CompactOutput) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CompactOutput.Unmarshal(m, b) return xxx_messageInfo_CompactOutput.Unmarshal(m, b)
@@ -278,30 +286,31 @@ func init() {
} }
func init() { func init() {
proto.RegisterFile("compact_formats.proto", fileDescriptor_compact_formats_e98cba77ef7a6fd2) proto.RegisterFile("compact_formats.proto", fileDescriptor_compact_formats_a15b2a7f016abebd)
} }
var fileDescriptor_compact_formats_e98cba77ef7a6fd2 = []byte{ var fileDescriptor_compact_formats_a15b2a7f016abebd = []byte{
// 332 bytes of a gzipped FileDescriptorProto // 346 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0x3f, 0x6b, 0xeb, 0x30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 0xc1, 0x6d, 0x0a, 0xb3, 0x22, 0x24, 0x6e,
0xc3, 0xe5, 0xd6, 0x1f, 0x69, 0x25, 0x5a, 0x02, 0xb0, 0x56, 0x36, 0x5c, 0x19, 0x3e, 0x18, 0xff, 0x53, 0xc4, 0x6b, 0x98, 0x1d, 0x25, 0x75, 0x7f, 0x5a, 0xef, 0xac, 0x43, 0x43, 0xad, 0x30, 0xbe,
0x95, 0x23, 0x67, 0x3d, 0x7b, 0x9a, 0x8e, 0x74, 0x4a, 0xb2, 0x97, 0xc4, 0xbd, 0xf8, 0xfa, 0x3b, 0xb1, 0x23, 0x35, 0x44, 0x0b, 0x00, 0x5a, 0xf1, 0x92, 0x09, 0xc5, 0x3a, 0x65, 0x2f, 0x76, 0xa0,
0x00, 0x00, 0xff, 0xff, 0xf7, 0x3a, 0x6a, 0x01, 0x40, 0x02, 0x00, 0x00, 0xac, 0xa6, 0x2f, 0x93, 0xbe, 0x9d, 0xe0, 0xf4, 0x2d, 0x30, 0xe7, 0xbf, 0xf9, 0x09, 0x00, 0x00,
0xff, 0xff, 0x22, 0x92, 0x05, 0x70, 0x5c, 0x02, 0x00, 0x00,
} }

View File

@@ -13,9 +13,10 @@ message CompactBlock {
uint32 protoVersion = 1; // the version of this wire format, for storage uint32 protoVersion = 1; // the version of this wire format, for storage
uint64 height = 2; // the height of this block uint64 height = 2; // the height of this block
bytes hash = 3; bytes hash = 3;
uint32 time = 4; bytes prevHash = 4;
bytes header = 5; // (hash and time) OR (full header) uint32 time = 5;
repeated CompactTx vtx = 6; // compact transactions from this block bytes header = 6; // (hash, prevHash, and time) OR (full header)
repeated CompactTx vtx = 7; // compact transactions from this block
} }
message CompactTx { message CompactTx {