Skip to content
This repository has been archived by the owner on Jun 6, 2023. It is now read-only.

Commit

Permalink
convert lane and nonce to uint64 (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
shannonwells authored and laser committed Feb 13, 2020
1 parent dc994d3 commit 08b1fcd
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 204 deletions.
258 changes: 66 additions & 192 deletions actors/builtin/paych/cbor_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions actors/builtin/paych/paych_actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ type SignedVoucher struct {
// (optional) Extra can be specified by `From` to add a verification method to the voucher
Extra *ModVerifyParams
// Specifies which lane the Voucher merges into (will be created if does not exist)
Lane int64
Lane uint64
// Nonce is set by `From` to prevent redemption of stale vouchers on a lane
Nonce int64
Nonce uint64
// Amount voucher can be redeemed for
Amount big.Int
// (optional) MinSettleHeight can extend channel MinSettleHeight if needed
Expand Down Expand Up @@ -324,11 +324,11 @@ func (t *SignedVoucher) SigningBytes() ([]byte, error) {
}

// Returns the insertion index for a lane ID, with the matching lane state if found, or nil.
func findLane(lanes []*LaneState, ID int64) (int, *LaneState) {
func findLane(lanes []*LaneState, ID uint64) (int, *LaneState) {
insertionIdx := sort.Search(len(lanes), func(i int) bool {
return lanes[i].ID >= ID
})
if insertionIdx == len(lanes) || lanes[insertionIdx].ID != int64(insertionIdx) {
if insertionIdx == len(lanes) || lanes[insertionIdx].ID != uint64(insertionIdx) {
// Not found
return insertionIdx, nil
}
Expand Down
8 changes: 4 additions & 4 deletions actors/builtin/paych/paych_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ type State struct {
// The Lane state tracks the latest (highest) voucher nonce used to merge the lane
// as well as the amount it has already redeemed.
type LaneState struct {
ID int64 // Unique to this channel
ID uint64 // Unique to this channel
Redeemed big.Int
Nonce int64
Nonce uint64
}

// Specifies which `Lane`s to be merged with what `Nonce` on channelUpdate
type Merge struct {
Lane int64
Nonce int64
Lane uint64
Nonce uint64
}

func ConstructState(from addr.Address, to addr.Address) *State {
Expand Down
8 changes: 4 additions & 4 deletions actors/builtin/paych/paych_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ func TestPaymentChannelActor_UpdateChannelState(t *testing.T) {
rt := builder.Build(t)
actor.constructAndVerify(rt, payerAddr, newPaychAddr)
amt := big.NewInt(10)
lane := int64(999)
nonce := int64(1)
lane := uint64(999)
nonce := uint64(1)
sig := &crypto.Signature{
Type: crypto.SigTypeBLS,
Data: []byte("doesn't matter"),
Expand Down Expand Up @@ -144,8 +144,8 @@ func TestPaymentChannelActor_UpdateChannelState(t *testing.T) {
actor.constructAndVerify(rt, payerAddr, newPaychAddr)
tl := abi.ChainEpoch(10)
amt := big.NewInt(9)
lane := int64(8)
nonce := int64(7)
lane := uint64(8)
nonce := uint64(7)
sig := &crypto.Signature{
Type: crypto.SigTypeBLS,
Data: []byte("doesn't matter"),
Expand Down

0 comments on commit 08b1fcd

Please sign in to comment.