mirror of
https://github.com/PeernetOfficial/core.git
synced 2026-07-17 02:47:51 +01:00
Blockchain: Fix bug in encodeBlockRecordFiles. Virtual tags were mistakenly counted, resulting in corruption.
This commit is contained in:
@@ -176,13 +176,15 @@ func encodeBlockRecordFiles(files []BlockRecordFile) (recordsRaw []BlockRecordRa
|
||||
data[88] = files[n].Type
|
||||
binary.LittleEndian.PutUint16(data[89:89+2], files[n].Format)
|
||||
binary.LittleEndian.PutUint64(data[91:91+8], files[n].Size)
|
||||
binary.LittleEndian.PutUint16(data[99:99+2], uint16(len(files[n].Tags)))
|
||||
|
||||
var tagCount uint16
|
||||
|
||||
for _, tag := range files[n].Tags {
|
||||
// Some tags are virtual and never stored on the blockchain. If attempted to write, ignore.
|
||||
if tag.IsVirtual() {
|
||||
continue
|
||||
}
|
||||
tagCount++
|
||||
|
||||
if len(tag.Data) > 4 {
|
||||
if refNumber, ok := duplicateTagDataMap[string(tag.Data)]; ok {
|
||||
@@ -201,6 +203,8 @@ func encodeBlockRecordFiles(files []BlockRecordFile) (recordsRaw []BlockRecordRa
|
||||
data = append(data, tag.Data...)
|
||||
}
|
||||
|
||||
binary.LittleEndian.PutUint16(data[99:99+2], tagCount)
|
||||
|
||||
recordsRaw = append(recordsRaw, BlockRecordRaw{Type: RecordTypeFile, Data: data})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user