Skip to content

Commit

Permalink
refactor: uint64 to uint32
Browse files Browse the repository at this point in the history
  • Loading branch information
nugaon committed Oct 5, 2023
1 parent 3c50960 commit 68e23ba
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pkg/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ func (m *mockContract) Claim(context.Context, []redistribution.Proof) (common.Ha
return common.Hash{}, nil
}

func (m *mockContract) Commit(context.Context, []byte, uint64) (common.Hash, error) {
func (m *mockContract) Commit(context.Context, []byte, uint32) (common.Hash, error) {
m.mtx.Lock()
defer m.mtx.Unlock()
m.callsList = append(m.callsList, commitCall)
Expand Down
2 changes: 1 addition & 1 deletion pkg/storageincentives/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ func (a *Agent) commit(ctx context.Context, sample sampler.Data, round uint64) e
return err
}

txHash, err := a.contract.Commit(ctx, obfuscatedHash, uint64(round))
txHash, err := a.contract.Commit(ctx, obfuscatedHash, uint32(round))
if err != nil {
a.metrics.ErrCommit.Inc()
return err
Expand Down
2 changes: 1 addition & 1 deletion pkg/storageincentives/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func (m *mockContract) Claim(context.Context, []redistribution.Proof) (common.Ha
return common.Hash{}, nil
}

func (m *mockContract) Commit(context.Context, []byte, uint64) (common.Hash, error) {
func (m *mockContract) Commit(context.Context, []byte, uint32) (common.Hash, error) {
m.mtx.Lock()
defer m.mtx.Unlock()
m.callsList = append(m.callsList, commitCall)
Expand Down
6 changes: 3 additions & 3 deletions pkg/storageincentives/redistribution/redistribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Contract interface {
IsPlaying(context.Context, uint8) (bool, error)
IsWinner(context.Context) (bool, error)
Claim(context.Context, []Proof) (common.Hash, error)
Commit(context.Context, []byte, uint64) (common.Hash, error)
Commit(context.Context, []byte, uint32) (common.Hash, error)
Reveal(context.Context, uint8, []byte, []byte) (common.Hash, error)
}

Expand Down Expand Up @@ -93,7 +93,7 @@ func (c *contract) IsWinner(ctx context.Context) (isWinner bool, err error) {

// Claim sends a transaction to blockchain if a win is claimed.
func (c *contract) Claim(ctx context.Context, proofs []Proof) (common.Hash, error) {
callData, err := c.incentivesContractABI.Pack("claim", proofs)
callData, err := c.incentivesContractABI.Pack("claim", proofs[0], proofs[1], proofs[2])
if err != nil {
return common.Hash{}, err
}
Expand All @@ -115,7 +115,7 @@ func (c *contract) Claim(ctx context.Context, proofs []Proof) (common.Hash, erro
}

// Commit submits the obfusHash hash by sending a transaction to the blockchain.
func (c *contract) Commit(ctx context.Context, obfusHash []byte, round uint64) (common.Hash, error) {
func (c *contract) Commit(ctx context.Context, obfusHash []byte, round uint32) (common.Hash, error) {
callData, err := c.incentivesContractABI.Pack("commit", common.BytesToHash(obfusHash), common.BytesToHash(c.overlay.Bytes()), round)
if err != nil {
return common.Hash{}, err
Expand Down
8 changes: 4 additions & 4 deletions pkg/storageincentives/redistribution/redistribution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func TestRedistribution(t *testing.T) {
var obfus [32]byte
testobfus := common.Hex2Bytes("hash")
copy(obfus[:], testobfus)
expectedCallData, err := redistributionContractABI.Pack("commit", obfus, common.BytesToHash(owner.Bytes()), uint64(0))
expectedCallData, err := redistributionContractABI.Pack("commit", obfus, common.BytesToHash(owner.Bytes()), uint32(0))
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -306,7 +306,7 @@ func TestRedistribution(t *testing.T) {
redistributionContractABI,
)

_, err = contract.Commit(ctx, testobfus, uint64(0))
_, err = contract.Commit(ctx, testobfus, uint32(0))
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -411,7 +411,7 @@ func TestRedistribution(t *testing.T) {
t.Run("invalid call data", func(t *testing.T) {
t.Parallel()

expectedCallData, err := redistributionContractABI.Pack("commit", common.BytesToHash(common.Hex2Bytes("some hash")), common.BytesToHash(common.Hex2Bytes("some address")), uint64(0))
expectedCallData, err := redistributionContractABI.Pack("commit", common.BytesToHash(common.Hex2Bytes("some hash")), common.BytesToHash(common.Hex2Bytes("some address")), uint32(0))
if err != nil {
t.Fatal(err)
}
Expand All @@ -433,7 +433,7 @@ func TestRedistribution(t *testing.T) {
redistributionContractABI,
)

_, err = contract.Commit(ctx, common.Hex2Bytes("hash"), uint64(0))
_, err = contract.Commit(ctx, common.Hex2Bytes("hash"), uint32(0))
if err == nil {
t.Fatal("expected error")
}
Expand Down

0 comments on commit 68e23ba

Please sign in to comment.