Skip to content

Commit

Permalink
improve metadata v15 decode
Browse files Browse the repository at this point in the history
  • Loading branch information
freehere107 committed Dec 16, 2024
1 parent 79267d4 commit 2ac6ea1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ func (m *MetadataDecoder) Init(data []byte) {

func (m *MetadataDecoder) Process() error {
magicBytes := m.NextBytes(4)
// if string(magicBytes) != "meta" {
// m.NextBytes(1) // maybe option<metadata> ?
// magicBytes = m.NextBytes(4)
// }
if string(magicBytes) != "meta" {
m.Data.Reset()
// option<Opaque<metadata>> version > v15
m.NextBytes(1) // 0x01
m.ProcessAndUpdateData("Compact<u32>") // Compact<u32>
magicBytes = m.NextBytes(4)
}
if string(magicBytes) == "meta" {
metadataVersion := utiles.U256(utiles.BytesToHex(m.Data.Data[m.Data.Offset : m.Data.Offset+1]))
m.Version = m.ProcessAndUpdateData("MetadataVersion").(string)
Expand Down
2 changes: 1 addition & 1 deletion metadata_test.go

Large diffs are not rendered by default.

0 comments on commit 2ac6ea1

Please sign in to comment.