github.com/MetalBlockchain/metalgo@v1.11.9/vms/platformvm/block/common_block.go (about) 1 // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 package block 5 6 import ( 7 "github.com/MetalBlockchain/metalgo/ids" 8 "github.com/MetalBlockchain/metalgo/utils/hashing" 9 ) 10 11 // CommonBlock contains fields and methods common to all blocks in this VM. 12 type CommonBlock struct { 13 // parent's ID 14 PrntID ids.ID `serialize:"true" json:"parentID"` 15 16 // This block's height. The genesis block is at height 0. 17 Hght uint64 `serialize:"true" json:"height"` 18 19 BlockID ids.ID `json:"id"` 20 bytes []byte 21 } 22 23 func (b *CommonBlock) initialize(bytes []byte) { 24 b.BlockID = hashing.ComputeHash256Array(bytes) 25 b.bytes = bytes 26 } 27 28 func (b *CommonBlock) ID() ids.ID { 29 return b.BlockID 30 } 31 32 func (b *CommonBlock) Parent() ids.ID { 33 return b.PrntID 34 } 35 36 func (b *CommonBlock) Bytes() []byte { 37 return b.bytes 38 } 39 40 func (b *CommonBlock) Height() uint64 { 41 return b.Hght 42 }