Files
platformvm/block_adapter.go
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

71 lines
1.6 KiB
Go

// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package platformvm
import (
"context"
"time"
"github.com/luxfi/vm/chain"
"github.com/luxfi/ids"
)
// blockAdapter wraps a chain.Block to implement linearblock.Block
type blockAdapter struct {
chain.Block
}
// Status returns the block status as choices.Status
func (b *blockAdapter) Status() uint8 {
// Return the uint8 status from the underlying block
return b.Block.Status()
}
// All other methods are delegated to the underlying block
func (b *blockAdapter) ID() ids.ID {
return b.Block.ID()
}
func (b *blockAdapter) ParentID() ids.ID {
return b.Block.ParentID()
}
func (b *blockAdapter) Height() uint64 {
return b.Block.Height()
}
func (b *blockAdapter) Timestamp() time.Time {
return b.Block.Timestamp()
}
func (b *blockAdapter) Bytes() []byte {
return b.Block.Bytes()
}
func (b *blockAdapter) Verify(ctx context.Context) error {
return b.Block.Verify(ctx)
}
func (b *blockAdapter) Accept(ctx context.Context) error {
return b.Block.Accept(ctx)
}
func (b *blockAdapter) Reject(ctx context.Context) error {
return b.Block.Reject(ctx)
}
func (b *blockAdapter) Options(ctx context.Context) ([2]chain.Block, error) {
// Options is not available in the chain.Block interface
// Return empty options for now
return [2]chain.Block{nil, nil}, nil
}
// wrapBlock wraps a chain.Block in an adapter that implements linearblock.Block
func wrapBlock(blk chain.Block) chain.Block {
if blk == nil {
return nil
}
return &blockAdapter{Block: blk}
}