Skip to content

Commit

Permalink
refactor: update TableExists name and TokenAmount type
Browse files Browse the repository at this point in the history
  • Loading branch information
hopeyen committed Oct 16, 2024
1 parent 4a50bf6 commit 3545713
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions common/aws/dynamodb/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,8 @@ func (c *Client) readItems(ctx context.Context, tableName string, keys []Key) ([
return items, nil
}

// TableCheck checks if a table exists and can be described
func (c *Client) TableCheck(ctx context.Context, name string) error {
// TableExists checks if a table exists and can be described
func (c *Client) TableExists(ctx context.Context, name string) error {
if name == "" {
return errors.New("table name is empty")
}
Expand Down
8 changes: 7 additions & 1 deletion core/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/binary"
"errors"
"fmt"
"math/big"

"github.com/Layr-Labs/eigenda/common"
"github.com/Layr-Labs/eigenda/encoding"
Expand Down Expand Up @@ -502,7 +503,12 @@ func (pm *PaymentMetadata) Hash() []byte {
return crypto.Keccak256(data)
}

type TokenAmount uint64 // TODO: change to uint128
type TokenAmount big.Int

// Add this new function
func NewTokenAmount(amount uint64) TokenAmount {
return TokenAmount(*big.NewInt(int64(amount)))
}

// OperatorInfo contains information about an operator which is stored on the blockchain state,
// corresponding to a particular quorum
Expand Down
6 changes: 3 additions & 3 deletions core/meterer/offchain_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ func NewOffchainStore(
return OffchainStore{}, err
}

err = dynamoClient.TableCheck(context.Background(), reservationTableName)
err = dynamoClient.TableExists(context.Background(), reservationTableName)
if err != nil {
return OffchainStore{}, err
}
err = dynamoClient.TableCheck(context.Background(), onDemandTableName)
err = dynamoClient.TableExists(context.Background(), onDemandTableName)
if err != nil {
return OffchainStore{}, err
}
err = dynamoClient.TableCheck(context.Background(), globalBinTableName)
err = dynamoClient.TableExists(context.Background(), globalBinTableName)
if err != nil {
return OffchainStore{}, err
}
Expand Down
2 changes: 1 addition & 1 deletion core/meterer/onchain_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var (
QuorumSplit: []byte{50, 50},
}
dummyOnDemandPayment = core.OnDemandPayment{
CumulativePayment: core.TokenAmount(1000),
CumulativePayment: core.NewTokenAmount(1000),
}
)

Expand Down

0 comments on commit 3545713

Please sign in to comment.