|
|
@ -3,6 +3,7 @@ package types |
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"errors" |
|
|
|
"errors" |
|
|
|
"math/big" |
|
|
|
"math/big" |
|
|
|
|
|
|
|
"sort" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common" |
|
|
|
"github.com/ethereum/go-ethereum/common" |
|
|
|
) |
|
|
|
) |
|
|
@ -59,7 +60,14 @@ func (d *Delegation) Undelegate(epoch *big.Int, amt *big.Int) error { |
|
|
|
if !exist { |
|
|
|
if !exist { |
|
|
|
item := UndelegationEntry{amt, epoch} |
|
|
|
item := UndelegationEntry{amt, epoch} |
|
|
|
d.Entries = append(d.Entries, &item) |
|
|
|
d.Entries = append(d.Entries, &item) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Always sort the undelegate by epoch in increasing order
|
|
|
|
|
|
|
|
sort.SliceStable( |
|
|
|
|
|
|
|
d.Entries, |
|
|
|
|
|
|
|
func(i, j int) bool { return d.Entries[i].Epoch.Cmp(d.Entries[j].Epoch) < 0 }, |
|
|
|
|
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|