Files
zeekay ede37547f6 refactor(platformvm): consolidate block code, drop atomic_block, add v0 lift
- Drop atomic_block.go + legacy *_block_test.go (consolidated)
- Add block/v0/ subdir + lift_v0.go for old version handling
- Copyright header: 'Lux Industries, Inc.' → 'Lux Industries Inc' (no comma)
- block_adapter.go: new adapter layer
2026-06-01 15:22:27 -07:00

56 lines
1.3 KiB
Go

// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package block
import (
"github.com/luxfi/runtime"
"fmt"
"time"
"github.com/luxfi/ids"
"github.com/luxfi/node/vms/platformvm/txs"
)
// RuntimeInitializable defines the interface for initializing context
type RuntimeInitializable interface {
InitRuntime(rt *runtime.Runtime)
}
// Block defines the common stateless interface for all blocks
type Block interface {
RuntimeInitializable
ID() ids.ID
Parent() ids.ID
Bytes() []byte
Height() uint64
// Txs returns list of transactions contained in the block
Txs() []*txs.Tx
// Visit calls [visitor] with this block's concrete type
Visit(visitor Visitor) error
// note: initialize does not assume that block transactions
// are initialized, and initializes them itself if they aren't.
initialize(bytes []byte) error
}
type TimestampedBlock interface {
Block
Timestamp() time.Time
}
func initialize(blk Block, commonBlk *CommonBlock) error {
// We serialize this block as a pointer so that it can be deserialized into
// a Block
bytes, err := Codec.Marshal(CodecVersion, &blk)
if err != nil {
return fmt.Errorf("couldn't marshal block: %w", err)
}
commonBlk.initialize(bytes)
return nil
}