diff --git a/api_v3.go b/api_v3.go index 43689dca1..617ae35ed 100644 --- a/api_v3.go +++ b/api_v3.go @@ -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))) diff --git a/attestation_test.go b/attestation_test.go index ffa40c467..7301d16cf 100644 --- a/attestation_test.go +++ b/attestation_test.go @@ -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) diff --git a/block.go b/block.go index 30ae0c049..8a2279c92 100644 --- a/block.go +++ b/block.go @@ -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 { @@ -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"` } @@ -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 @@ -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 { @@ -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 { diff --git a/block_test.go b/block_test.go index feb7fd9f4..737159b6d 100644 --- a/block_test.go +++ b/block_test.go @@ -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, diff --git a/builder/block_builder_test.go b/builder/block_builder_test.go index cba1b8d83..8eee86162 100644 --- a/builder/block_builder_test.go +++ b/builder/block_builder_test.go @@ -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()) @@ -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) diff --git a/tpkg/util.go b/tpkg/util.go index e779cf816..5d286c081 100644 --- a/tpkg/util.go +++ b/tpkg/util.go @@ -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 {