github.com/MetalBlockchain/metalgo@v1.11.9/vms/proposervm/summary/parse.go (about) 1 // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 package summary 5 6 import ( 7 "fmt" 8 9 "github.com/MetalBlockchain/metalgo/utils/hashing" 10 ) 11 12 func Parse(bytes []byte) (StateSummary, error) { 13 summary := stateSummary{ 14 id: hashing.ComputeHash256Array(bytes), 15 bytes: bytes, 16 } 17 version, err := Codec.Unmarshal(bytes, &summary) 18 if err != nil { 19 return nil, fmt.Errorf("could not unmarshal summary due to: %w", err) 20 } 21 if version != CodecVersion { 22 return nil, errWrongCodecVersion 23 } 24 return &summary, nil 25 }