Skip to content

Commit

Permalink
refactor: add and rm comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hopeyen committed Oct 25, 2024
1 parent bd0ecce commit c1aae4d
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 8 deletions.
2 changes: 1 addition & 1 deletion core/auth/payment_signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ func NewPaymentSigner(privateKeyHex string) *PaymentSigner {
}
}

// SignBlobPayment signs the payment header and returns the signature
func (s *PaymentSigner) SignBlobPayment(header *commonpb.PaymentHeader) ([]byte, error) {
// Set the account id to the hex encoded public key of the signer
header.AccountId = s.GetAccountID()
pm := core.ConvertPaymentHeader(header)
hash := pm.Hash()
Expand Down
2 changes: 0 additions & 2 deletions core/auth/payment_signer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ import (
)

func TestPaymentSigner(t *testing.T) {
// Generate a new private key for testing
privateKey, err := crypto.GenerateKey()
// publicKey := &privateKey.PublicKey
require.NoError(t, err)

privateKeyHex := hex.EncodeToString(crypto.FromECDSA(privateKey))
Expand Down
3 changes: 0 additions & 3 deletions core/meterer/meterer.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,16 +239,13 @@ func (m *Meterer) ValidatePayment(ctx context.Context, header core.PaymentMetada

// PaymentCharged returns the chargeable price for a given data length
func (m *Meterer) PaymentCharged(dataLength uint) uint64 {
fmt.Println("PaymentCharged", dataLength, m.SymbolsCharged(dataLength), m.ChainPaymentState.GetPricePerSymbol())
return uint64(m.SymbolsCharged(dataLength)) * uint64(m.ChainPaymentState.GetPricePerSymbol())
}

// SymbolsCharged returns the number of symbols charged for a given data length
// being at least MinNumSymbols or the nearest rounded-up multiple of MinNumSymbols.
func (m *Meterer) SymbolsCharged(dataLength uint) uint32 {
fmt.Println("SymbolsCharged", dataLength, m.ChainPaymentState.GetMinNumSymbols())
if dataLength <= uint(m.ChainPaymentState.GetMinNumSymbols()) {
fmt.Println("return ", m.ChainPaymentState.GetMinNumSymbols())
return m.ChainPaymentState.GetMinNumSymbols()
}
// Round up to the nearest multiple of MinNumSymbols
Expand Down
1 change: 0 additions & 1 deletion core/meterer/onchain_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ func (pcs *OnchainPaymentState) GetOnDemandPaymentByAccount(ctx context.Context,
}

func (pcs *OnchainPaymentState) GetOnDemandPaymentByAccountOnChain(ctx context.Context, accountID string) (core.OnDemandPayment, error) {
// pulls the chain state
blockNumber, err := pcs.tx.GetCurrentBlockNumber(ctx)
if err != nil {
return core.OnDemandPayment{}, err
Expand Down
1 change: 0 additions & 1 deletion disperser/apiserver/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ func TestDisperseBlobWithInvalidQuorum(t *testing.T) {
}
ctx := peer.NewContext(context.Background(), p)

// (*dispersalServer).tx.On("GetRequiredQuorumNumbers", tmock.Anything).Return([]uint8{0, 1}, nil).Twice()
_, err = dispersalServer.DisperseBlob(ctx, &pb.DisperseBlobRequest{
Data: data,
CustomQuorumNumbers: []uint32{2},
Expand Down

0 comments on commit c1aae4d

Please sign in to comment.