Skip to content

Commit

Permalink
refactor: move block to ledger/common w/ compat (#799)
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Gianelloni <[email protected]>
  • Loading branch information
wolf31o2 authored Nov 22, 2024
1 parent 177d2d2 commit 79d22a1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 deletions.
24 changes: 5 additions & 19 deletions ledger/block.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Blink Labs Software
// Copyright 2024 Blink Labs Software
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -17,26 +17,12 @@ package ledger
import (
"fmt"

utxorpc "github.com/utxorpc/go-codegen/utxorpc/v1alpha/cardano"
"github.com/blinklabs-io/gouroboros/ledger/common"
)

type Block interface {
BlockHeader
Type() int
Transactions() []Transaction
Utxorpc() *utxorpc.Block
}

type BlockHeader interface {
Hash() string
PrevHash() string
BlockNumber() uint64
SlotNumber() uint64
IssuerVkey() IssuerVkey
BlockBodySize() uint64
Era() Era
Cbor() []byte
}
// Compatibility aliases
type Block = common.Block
type BlockHeader = common.BlockHeader

func NewBlockFromCbor(blockType uint, data []byte) (Block, error) {
switch blockType {
Expand Down
21 changes: 21 additions & 0 deletions ledger/common/block.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package common

import utxorpc "github.com/utxorpc/go-codegen/utxorpc/v1alpha/cardano"

type Block interface {
BlockHeader
Type() int
Transactions() []Transaction
Utxorpc() *utxorpc.Block
}

type BlockHeader interface {
Hash() string
PrevHash() string
BlockNumber() uint64
SlotNumber() uint64
IssuerVkey() IssuerVkey
BlockBodySize() uint64
Era() Era
Cbor() []byte
}

0 comments on commit 79d22a1

Please sign in to comment.