Skip to content

Commit

Permalink
Rename StorageScoreStructure methods
Browse files Browse the repository at this point in the history
  • Loading branch information
jkrvivian committed Oct 18, 2023
1 parent f9de99b commit 9f891a4
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion api_v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func V3API(protoParams ProtocolParameters) API {
v3 := &v3api{
serixAPI: api,
protocolParameters: protoParams.(*V3ProtocolParameters),
storageScoreStructure: NewRentStructure(protoParams.RentParameters()),
storageScoreStructure: NewStorageScoreStructure(protoParams.RentParameters()),
timeProvider: timeProvider,
manaDecayProvider: protoParams.ManaDecayProvider(),
maxBlockWork: maxBlockWork,
Expand Down
2 changes: 1 addition & 1 deletion block_issuer_key_ed25519_pubkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ func (key *Ed25519PublicKeyBlockIssuerKey) Size() int {
}

func (key *Ed25519PublicKeyBlockIssuerKey) StorageScore(storageScoreStruct *StorageScoreStructure, _ StorageScoreFunc) StorageScore {
return storageScoreStruct.StorageScoreOffsetEd25519BlockIssuerKey()
return storageScoreStruct.OffsetEd25519BlockIssuerKey()
}
2 changes: 1 addition & 1 deletion block_issuer_key_ed25519_pubkeyhash.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,5 @@ func (key *Ed25519PublicKeyHashBlockIssuerKey) Size() int {
}

func (key *Ed25519PublicKeyHashBlockIssuerKey) StorageScore(storageScoreStructure *StorageScoreStructure, _ StorageScoreFunc) StorageScore {
return storageScoreStructure.StorageScoreOffsetEd25519BlockIssuerKey()
return storageScoreStructure.OffsetEd25519BlockIssuerKey()
}
2 changes: 1 addition & 1 deletion builder/transaction_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func CalculateAvailableMana(protoParams iotago.ProtocolParameters, inputSet iota
var potentialMana iotago.Mana

// we need to ignore the storage deposit, because it doesn't generate mana
minDeposit, err := iotago.NewRentStructure(protoParams.RentParameters()).MinDeposit(input)
minDeposit, err := iotago.NewStorageScoreStructure(protoParams.RentParameters()).MinDeposit(input)
if err != nil {
return 0, 0, nil, ierrors.Wrap(err, "failed to calculate min deposit")
}
Expand Down
2 changes: 1 addition & 1 deletion feat_staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (s *StakingFeature) StorageScore(storageScoreStruct *StorageScoreStructure,
return f(storageScoreStruct)
}

return storageScoreStruct.StorageScoreOffsetStakingFeature()
return storageScoreStruct.OffsetStakingFeature()
}

func (s *StakingFeature) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error) {
Expand Down
4 changes: 2 additions & 2 deletions output.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ var (

// defines the default storage score offset for an output.
func offsetOutput(storageScoreStruct *StorageScoreStructure) StorageScore {
return storageScoreStruct.StorageScoreOffsetOutput() +
return storageScoreStruct.OffsetOutput() +
// included output id, block id, and slot booked data size
storageScoreStruct.StorageScoreFactorData().Multiply(OutputIDLength+BlockIDLength+SlotIndexLength)
storageScoreStruct.FactorData().Multiply(OutputIDLength+BlockIDLength+SlotIndexLength)
}

// OutputSet is a map of the OutputID to Output.
Expand Down
2 changes: 1 addition & 1 deletion output_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (a *AccountOutput) UnlockableBy(ident Address, next TransDepIdentOutput, pa

func (a *AccountOutput) StorageScore(storageScoreStruct *StorageScoreStructure, _ StorageScoreFunc) StorageScore {
return offsetOutput(storageScoreStruct) +
storageScoreStruct.StorageScoreFactorData().Multiply(StorageScore(a.Size())) +
storageScoreStruct.FactorData().Multiply(StorageScore(a.Size())) +
a.Conditions.StorageScore(storageScoreStruct, nil) +
a.Features.StorageScore(storageScoreStruct, nil) +
a.ImmutableFeatures.StorageScore(storageScoreStruct, nil)
Expand Down
2 changes: 1 addition & 1 deletion output_basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (e *BasicOutput) UnlockableBy(ident Address, pastBoundedSlotIndex SlotIndex

func (e *BasicOutput) StorageScore(storageScoreStruct *StorageScoreStructure, _ StorageScoreFunc) StorageScore {
return offsetOutput(storageScoreStruct) +
storageScoreStruct.StorageScoreFactorData().Multiply(StorageScore(e.Size())) +
storageScoreStruct.FactorData().Multiply(StorageScore(e.Size())) +
e.Conditions.StorageScore(storageScoreStruct, nil) +
e.Features.StorageScore(storageScoreStruct, nil)
}
Expand Down
4 changes: 2 additions & 2 deletions output_delegation.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ func (d *DelegationOutput) UnlockableBy(ident Address, pastBoundedSlot SlotIndex

func (d *DelegationOutput) StorageScore(storageScoreStruct *StorageScoreStructure, _ StorageScoreFunc) StorageScore {
return offsetOutput(storageScoreStruct) +
storageScoreStruct.StorageScoreFactorData().Multiply(StorageScore(d.Size())) +
storageScoreStruct.StorageScoreOffsetDelegation() +
storageScoreStruct.FactorData().Multiply(StorageScore(d.Size())) +
storageScoreStruct.OffsetDelegation() +
d.Conditions.StorageScore(storageScoreStruct, nil)
}

Expand Down
2 changes: 1 addition & 1 deletion output_foundry.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (f *FoundryOutput) UnlockableBy(ident Address, pastBoundedSlotIndex SlotInd

func (f *FoundryOutput) StorageScore(storageScoreStruct *StorageScoreStructure, _ StorageScoreFunc) StorageScore {
return offsetOutput(storageScoreStruct) +
storageScoreStruct.StorageScoreFactorData().Multiply(StorageScore(f.Size())) +
storageScoreStruct.FactorData().Multiply(StorageScore(f.Size())) +
f.TokenScheme.StorageScore(storageScoreStruct, nil) +
f.Conditions.StorageScore(storageScoreStruct, nil) +
f.Features.StorageScore(storageScoreStruct, nil) +
Expand Down
2 changes: 1 addition & 1 deletion output_nft.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (n *NFTOutput) UnlockableBy(ident Address, pastBoundedSlotIndex SlotIndex,

func (n *NFTOutput) StorageScore(storageScoreStruct *StorageScoreStructure, _ StorageScoreFunc) StorageScore {
return offsetOutput(storageScoreStruct) +
storageScoreStruct.StorageScoreFactorData().Multiply(StorageScore(n.Size())) +
storageScoreStruct.FactorData().Multiply(StorageScore(n.Size())) +
n.Conditions.StorageScore(storageScoreStruct, nil) +
n.Features.StorageScore(storageScoreStruct, nil) +
n.ImmutableFeatures.StorageScore(storageScoreStruct, nil)
Expand Down
2 changes: 1 addition & 1 deletion output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ func TestOutputsSyntacticalDepositAmount(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
valFunc := iotago.OutputsSyntacticalDepositAmount(tt.protoParams, iotago.NewRentStructure(tt.protoParams.RentParameters()))
valFunc := iotago.OutputsSyntacticalDepositAmount(tt.protoParams, iotago.NewStorageScoreStructure(tt.protoParams.RentParameters()))
var runErr error
for index, output := range tt.outputs {
if err := valFunc(index, output); err != nil {
Expand Down
24 changes: 12 additions & 12 deletions rent.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,33 +63,33 @@ func (r *StorageScoreStructure) StorageCost() BaseToken {
return r.StorageScoreParameters.StorageCost
}

// StorageScoreFactorData returns the factor to be used for data only fields.
func (r *StorageScoreStructure) StorageScoreFactorData() StorageScoreFactor {
// FactorData returns the factor to be used for data only fields.
func (r *StorageScoreStructure) FactorData() StorageScoreFactor {
return r.StorageScoreParameters.FactorData
}

// StorageScoreOffsetOutput returns the offset to be used for all outputs to account for metadata created for the output.
func (r *StorageScoreStructure) StorageScoreOffsetOutput() StorageScore {
// OffsetOutput returns the offset to be used for all outputs to account for metadata created for the output.
func (r *StorageScoreStructure) OffsetOutput() StorageScore {
return r.StorageScoreParameters.OffsetOutput
}

// StorageScoreOffsetEd25519BlockIssuerKey returns the offset to be used for block issuer feature public keys.
func (r *StorageScoreStructure) StorageScoreOffsetEd25519BlockIssuerKey() StorageScore {
// OffsetEd25519BlockIssuerKey returns the offset to be used for block issuer feature public keys.
func (r *StorageScoreStructure) OffsetEd25519BlockIssuerKey() StorageScore {
return r.StorageScoreParameters.OffsetEd25519BlockIssuerKey
}

// StorageScoreOffsetStakingFeature returns the offset to be used for staking feature.
func (r *StorageScoreStructure) StorageScoreOffsetStakingFeature() StorageScore {
// OffsetStakingFeature returns the offset to be used for staking feature.
func (r *StorageScoreStructure) OffsetStakingFeature() StorageScore {
return r.StorageScoreParameters.OffsetStakingFeature
}

// StorageScoreOffsetDelegation returns the offset to be used for delegation output.
func (r *StorageScoreStructure) StorageScoreOffsetDelegation() StorageScore {
// OffsetDelegation returns the offset to be used for delegation output.
func (r *StorageScoreStructure) OffsetDelegation() StorageScore {
return r.StorageScoreParameters.OffsetDelegation
}

// NewRentStructure creates a new RentStructure.
func NewRentStructure(rentParameters *StorageScoreParameters) *StorageScoreStructure {
// NewStorageScoreStructure creates a new RentStructure.
func NewStorageScoreStructure(rentParameters *StorageScoreParameters) *StorageScoreStructure {
// create a dummy account with a block issuer feature to calculate the storage score.
dummyAccountOutput := &AccountOutput{
Amount: 0,
Expand Down
4 changes: 2 additions & 2 deletions vm/nova/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5809,7 +5809,7 @@ func TestTxSemanticMana(t *testing.T) {
targetSlot := 10 + 100*testProtoParams.ParamEpochDurationInSlots()

input := inputs[inputIDs[0]]
storageScoreStructure := iotago.NewRentStructure(testProtoParams.RentParameters())
storageScoreStructure := iotago.NewStorageScoreStructure(testProtoParams.RentParameters())
minDeposit, err := storageScoreStructure.MinDeposit(input)
require.NoError(t, err)
excessBaseTokens, err := safemath.SafeSub(input.BaseTokenAmount(), minDeposit)
Expand Down Expand Up @@ -5878,7 +5878,7 @@ func TestTxSemanticMana(t *testing.T) {
targetSlot := 10 + 100*testProtoParams.ParamEpochDurationInSlots()

input := inputs[inputIDs[0]]
storageScoreStructure := iotago.NewRentStructure(testProtoParams.RentParameters())
storageScoreStructure := iotago.NewStorageScoreStructure(testProtoParams.RentParameters())
minDeposit, err := storageScoreStructure.MinDeposit(input)
require.NoError(t, err)
excessBaseTokens, err := safemath.SafeSub(input.BaseTokenAmount(), minDeposit)
Expand Down

0 comments on commit 9f891a4

Please sign in to comment.