Skip to content

Commit

Permalink
Rename Block -> BlockBody
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippGackstatter committed Oct 27, 2023
1 parent 2e13e51 commit 80d46a3
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
8 changes: 4 additions & 4 deletions api_v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -600,19 +600,19 @@ func V3API(protoParams ProtocolParameters) API {

{
must(api.RegisterTypeSettings(BasicBlock{},
serix.TypeSettings{}.WithObjectType(byte(BlockTypeBasic))),
serix.TypeSettings{}.WithObjectType(byte(BlockBodyTypeBasic))),
)
}

{
must(api.RegisterTypeSettings(ValidationBlock{},
serix.TypeSettings{}.WithObjectType(byte(BlockTypeValidation))),
serix.TypeSettings{}.WithObjectType(byte(BlockBodyTypeValidation))),
)
}

{
must(api.RegisterInterfaceObjects((*Block)(nil), (*BasicBlock)(nil)))
must(api.RegisterInterfaceObjects((*Block)(nil), (*ValidationBlock)(nil)))
must(api.RegisterInterfaceObjects((*BlockBody)(nil), (*BasicBlock)(nil)))
must(api.RegisterInterfaceObjects((*BlockBody)(nil), (*ValidationBlock)(nil)))

must(api.RegisterInterfaceObjects((*ApplicationPayload)(nil), (*SignedTransaction)(nil)))
must(api.RegisterInterfaceObjects((*ApplicationPayload)(nil), (*TaggedData)(nil)))
Expand Down
2 changes: 1 addition & 1 deletion attestation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestAttestation(t *testing.T) {
Build()

require.NoError(t, err)
require.Equal(t, iotago.BlockTypeValidation, block.Block.Type())
require.Equal(t, iotago.BlockBodyTypeValidation, block.Block.Type())

attestation := iotago.NewAttestation(tpkg.TestAPI, block)

Expand Down
22 changes: 11 additions & 11 deletions block.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ var (
ErrCommitmentInputNewerThanCommitment = ierrors.New("a block cannot contain a commitment input with index newer than the commitment index")
)

// BlockType denotes a type of Block.
type BlockType byte
// BlockBodyType denotes a type of Block Body.
type BlockBodyType byte

const (
BlockTypeBasic BlockType = 0
BlockTypeValidation BlockType = 1
BlockBodyTypeBasic BlockBodyType = 0
BlockBodyTypeValidation BlockBodyType = 1
)

type ApplicationPayload interface {
Expand Down Expand Up @@ -85,7 +85,7 @@ func (b *BlockHeader) Size() int {
type ProtocolBlock struct {
API API
BlockHeader `serix:"0,nest"`
Block Block `serix:"1,mapKey=block"`
Block BlockBody `serix:"1,mapKey=block"`
Signature Signature `serix:"2,mapKey=signature"`
}

Expand Down Expand Up @@ -312,8 +312,8 @@ func (b *ProtocolBlock) syntacticallyValidate() error {
return b.Block.syntacticallyValidate(b)
}

type Block interface {
Type() BlockType
type BlockBody interface {
Type() BlockBodyType

StrongParentIDs() BlockIDs
WeakParentIDs() BlockIDs
Expand Down Expand Up @@ -346,8 +346,8 @@ func (b *BasicBlock) SetDeserializationContext(ctx context.Context) {
b.API = APIFromContext(ctx)
}

func (b *BasicBlock) Type() BlockType {
return BlockTypeBasic
func (b *BasicBlock) Type() BlockBodyType {
return BlockBodyTypeBasic
}

func (b *BasicBlock) StrongParentIDs() BlockIDs {
Expand Down Expand Up @@ -464,8 +464,8 @@ func (b *ValidationBlock) SetDeserializationContext(ctx context.Context) {
b.API = APIFromContext(ctx)
}

func (b *ValidationBlock) Type() BlockType {
return BlockTypeValidation
func (b *ValidationBlock) Type() BlockBodyType {
return BlockBodyTypeValidation
}

func (b *ValidationBlock) StrongParentIDs() BlockIDs {
Expand Down
2 changes: 1 addition & 1 deletion block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ func TestBlockJSONMarshalling(t *testing.T) {
strconv.FormatUint(serializer.TimeToUint64(issuingTime), 10),
commitmentID.ToHex(),
issuerID.ToHex(),
iotago.BlockTypeValidation,
iotago.BlockBodyTypeValidation,
strongParents[0].ToHex(),
tpkg.TestAPI.Version(),
iotago.SignatureEd25519,
Expand Down
4 changes: 2 additions & 2 deletions builder/block_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestBasicBlockBuilder(t *testing.T) {
Build()
require.NoError(t, err)

require.Equal(t, iotago.BlockTypeBasic, block.Block.Type())
require.Equal(t, iotago.BlockBodyTypeBasic, block.Block.Type())

basicBlock := block.Block.(*iotago.BasicBlock)
expectedBurnedMana, err := basicBlock.ManaCost(100, tpkg.TestAPI.ProtocolParameters().WorkScoreParameters())
Expand All @@ -42,7 +42,7 @@ func TestValidationBlockBuilder(t *testing.T) {
Build()
require.NoError(t, err)

require.Equal(t, iotago.BlockTypeValidation, block.Block.Type())
require.Equal(t, iotago.BlockBodyTypeValidation, block.Block.Type())

basicBlock := block.Block.(*iotago.ValidationBlock)
require.EqualValues(t, 100, basicBlock.HighestSupportedVersion)
Expand Down
2 changes: 1 addition & 1 deletion tpkg/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ func RandBlockID() iotago.BlockID {
}

// RandProtocolBlock returns a random block with the given inner payload.
func RandProtocolBlock(block iotago.Block, api iotago.API, rmc iotago.Mana) *iotago.ProtocolBlock {
func RandProtocolBlock(block iotago.BlockBody, api iotago.API, rmc iotago.Mana) *iotago.ProtocolBlock {
if basicBlock, isBasic := block.(*iotago.BasicBlock); isBasic {
burnedMana, err := basicBlock.ManaCost(rmc, api.ProtocolParameters().WorkScoreParameters())
if err != nil {
Expand Down

0 comments on commit 80d46a3

Please sign in to comment.