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