Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

swap: unify variable types, pt. 4 #2087

Open
wants to merge 91 commits into
base: master
Choose a base branch
from

Conversation

mortelli
Copy link
Contributor

@mortelli mortelli commented Feb 3, 2020

This PR is the 4th and final part of implementing issue #1581, which aims at unifying variable types between the SWAP smart contracts and the related code on the go side.

Changes:

  • Peer balance field is now *Int256-typed, instead of int64
    • related Peer funcs have their signature updated to match this change
    • RPCs that return balance data now return *Int256-typed results, instead of int64
  • Cmp and Equals now work interchangeably between *Int256 and *Uint256 types
    • BigIntWrapper interface was added for this
  • payment and disconnect thresholds are now *Uint256-typed, instead of uint64
    • these need to be vars rather than consts now, since they have to be computed at run-time
  • updated tests based on these changes

@mortelli mortelli added in progress incentives builds on open PR Builds on a PR that is not yet merged. It is blocked until then and the diff won't make sense yet. labels Feb 3, 2020
@mortelli mortelli self-assigned this Feb 3, 2020
…py and set funcs for Int256 and Uint256 structs
…rror in Int256 and Uint256 DecodeRLP funcs, iterate func comments
…nto swap-unify-variable-types-iv

# Conflicts:
#	swap/int256/int256.go
#	swap/int256/uint256.go
…arshaling functions to prevent json number overflow
…nto swap-unify-variable-types-iv

# Conflicts:
#	swap/peer.go
#	swap/swap.go
…-types-iv

# Conflicts:
#	swap/api.go
#	swap/int256/int256.go
#	swap/int256/uint256.go
#	swap/protocol_test.go
#	swap/swap.go
#	swap/swap_test.go
@mortelli mortelli removed the builds on open PR Builds on a PR that is not yet merged. It is blocked until then and the diff won't make sense yet. label Mar 30, 2020
…le, fix swap logic and tests to work with new pointer semantics in int256
@mortelli mortelli marked this pull request as ready for review March 30, 2020 21:07
Copy link
Member

@acud acud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but one small comment about the big int wrapper. not sure why this is needed


// test balances after balance change for peer
setBalance(t, testPeer, 303)
testBalances(t, swap, map[enode.ID]int64{testPeerID: 303, testPeer2ID: 123})
balancePeer = int256.Int256From(303)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my favorite :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am somewhat partial to 909 as well 😛

swap/int256/int256.go Show resolved Hide resolved
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants