Skip to content

Commit

Permalink
refactor: use pointer for big int
Browse files Browse the repository at this point in the history
  • Loading branch information
hopeyen committed Oct 16, 2024
1 parent fc9f7cf commit b956ae0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions core/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,8 @@ type ActiveReservation struct {
StartTimestamp uint64 // Unix timestamp that's valid for basically eternity
EndTimestamp uint64

QuorumNumbers []uint8
QuorumSplit []byte // ordered mapping of quorum number to payment split; on-chain validation should ensure split <= 100
QuorumNumbers []uint8 // allowed quorums
QuorumSplit []byte // ordered mapping of quorum number to payment split; on-chain validation should ensure split <= 100
}

type OnDemandPayment struct {
Expand Down
2 changes: 1 addition & 1 deletion core/meterer/meterer.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func (m *Meterer) ServeOnDemandRequest(ctx context.Context, header core.PaymentM
// <= PaymentMetadata.CumulativePayment
// <= nextPmt - nextPmtDataLength * m.FixedFeePerByte > nextPmt
func (m *Meterer) ValidatePayment(ctx context.Context, header core.PaymentMetadata, onDemandPayment *core.OnDemandPayment, blobLength uint) error {
if header.CumulativePayment.Cmp(&onDemandPayment.CumulativePayment) > 0 {
if header.CumulativePayment.Cmp(onDemandPayment.CumulativePayment) > 0 {
return fmt.Errorf("request claims a cumulative payment greater than the on-chain deposit")
}

Expand Down
4 changes: 2 additions & 2 deletions core/meterer/meterer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ func setup(_ *testing.M) {
accountID2 = crypto.PubkeyToAddress(privateKey2.PublicKey).Hex()
account1Reservations = core.ActiveReservation{SymbolsPerSec: 100, StartTimestamp: now + 1200, EndTimestamp: now + 1800, QuorumSplit: []byte{50, 50}, QuorumNumbers: []uint8{0, 1}}
account2Reservations = core.ActiveReservation{SymbolsPerSec: 200, StartTimestamp: now - 120, EndTimestamp: now + 180, QuorumSplit: []byte{30, 70}, QuorumNumbers: []uint8{0, 1}}
account1OnDemandPayments = core.OnDemandPayment{CumulativePayment: *big.NewInt(3864)}
account2OnDemandPayments = core.OnDemandPayment{CumulativePayment: *big.NewInt(2000)}
account1OnDemandPayments = core.OnDemandPayment{CumulativePayment: big.NewInt(3864)}
account2OnDemandPayments = core.OnDemandPayment{CumulativePayment: big.NewInt(2000)}

store, err := meterer.NewOffchainStore(
clientConfig,
Expand Down

0 comments on commit b956ae0

Please sign in to comment.