mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 11:26:44 +01:00
ItemID to uint64 & check timestamp
This commit is contained in:
@@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
type testAccount struct {
|
||||
ItemID int `json:"itemId"`
|
||||
ItemID uint64 `json:"itemId"`
|
||||
Idx apitypes.HezIdx `json:"accountIndex"`
|
||||
BatchNum common.BatchNum `json:"batchNum"`
|
||||
PublicKey apitypes.HezBJJ `json:"bjj"`
|
||||
@@ -34,7 +34,7 @@ func genTestAccounts(accounts []common.Account, tokens []historydb.TokenWithUSD)
|
||||
for x, account := range accounts {
|
||||
token := getTokenByID(account.TokenID, tokens)
|
||||
tAccount := testAccount{
|
||||
ItemID: x + 1,
|
||||
ItemID: uint64(x + 1),
|
||||
Idx: apitypes.HezIdx(idxToHez(account.Idx, token.Symbol)),
|
||||
PublicKey: apitypes.NewHezBJJ(account.PublicKey),
|
||||
EthAddr: apitypes.NewHezEthAddr(account.EthAddr),
|
||||
|
||||
@@ -364,13 +364,13 @@ func doGoodReqPaginated(
|
||||
if pag.LastReturnedItem == pag.LastItem { // No
|
||||
break
|
||||
} else { // Yes
|
||||
next = pag.LastReturnedItem + 1
|
||||
next = int(pag.LastReturnedItem + 1)
|
||||
}
|
||||
} else {
|
||||
if pag.FirstReturnedItem == pag.FirstItem { // No
|
||||
break
|
||||
} else { // Yes
|
||||
next = pag.FirstReturnedItem - 1
|
||||
next = int(pag.FirstReturnedItem - 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
type testBatch struct {
|
||||
ItemID int `json:"itemId"`
|
||||
ItemID uint64 `json:"itemId"`
|
||||
BatchNum common.BatchNum `json:"batchNum"`
|
||||
EthBlockNum int64 `json:"ethereumBlockNum"`
|
||||
EthBlockHash ethCommon.Hash `json:"ethereumBlockHash"`
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
type testBid struct {
|
||||
ItemID int `json:"itemId"`
|
||||
ItemID uint64 `json:"itemId"`
|
||||
SlotNum int64 `json:"slotNum"`
|
||||
BidValue string `json:"bidValue"`
|
||||
EthBlockNum int64 `json:"ethereumBlockNum"`
|
||||
|
||||
@@ -24,7 +24,7 @@ type testCVP struct {
|
||||
}
|
||||
|
||||
type testExit struct {
|
||||
ItemID int `json:"itemId"`
|
||||
ItemID uint64 `json:"itemId"`
|
||||
BatchNum common.BatchNum `json:"batchNum"`
|
||||
AccountIdx string `json:"accountIndex"`
|
||||
MerkleProof testCVP `json:"merkleProof"`
|
||||
|
||||
36
api/slots.go
36
api/slots.go
@@ -13,15 +13,15 @@ import (
|
||||
|
||||
// SlotAPI is a repesentation of a slot information
|
||||
type SlotAPI struct {
|
||||
ItemID int `json:"itemId"`
|
||||
ItemID uint64 `json:"itemId"`
|
||||
SlotNum int64 `json:"slotNum"`
|
||||
FirstBlock int64 `json:"firstBlock"`
|
||||
LastBlock int64 `json:"lastBlock"`
|
||||
OpenAuction bool `json:"openAuction"`
|
||||
WinnerBid *historydb.BidAPI `json:"winnerBid"`
|
||||
TotalItems int `json:"-"`
|
||||
FirstItem int `json:"-"`
|
||||
LastItem int `json:"-"`
|
||||
TotalItems uint64 `json:"-"`
|
||||
FirstItem uint64 `json:"-"`
|
||||
LastItem uint64 `json:"-"`
|
||||
}
|
||||
|
||||
func getFirstLastBlock(slotNum int64) (int64, int64) {
|
||||
@@ -49,14 +49,14 @@ func isOpenAuction(currentBlock, slotNum int64, auctionVars common.AuctionVariab
|
||||
return false
|
||||
}
|
||||
|
||||
func getPagination(totalItems int, minSlotNum, maxSlotNum *int64) *db.Pagination {
|
||||
func getPagination(totalItems uint64, minSlotNum, maxSlotNum *int64) *db.Pagination {
|
||||
// itemID is slotNum
|
||||
firstItem := *minSlotNum
|
||||
lastItem := *maxSlotNum
|
||||
pagination := &db.Pagination{
|
||||
TotalItems: int(totalItems),
|
||||
FirstItem: int(firstItem),
|
||||
LastItem: int(lastItem),
|
||||
TotalItems: totalItems,
|
||||
FirstItem: uint64(firstItem),
|
||||
LastItem: uint64(lastItem),
|
||||
}
|
||||
return pagination
|
||||
}
|
||||
@@ -65,7 +65,7 @@ func newSlotAPI(slotNum, currentBlockNum int64, bid *historydb.BidAPI, auctionVa
|
||||
firstBlock, lastBlock := getFirstLastBlock(slotNum)
|
||||
openAuction := isOpenAuction(currentBlockNum, slotNum, *auctionVars)
|
||||
slot := SlotAPI{
|
||||
ItemID: int(slotNum),
|
||||
ItemID: uint64(slotNum),
|
||||
SlotNum: slotNum,
|
||||
FirstBlock: firstBlock,
|
||||
LastBlock: lastBlock,
|
||||
@@ -80,11 +80,11 @@ func newSlotsAPIFromWinnerBids(fromItem *uint, order string, bids []historydb.Bi
|
||||
slotNum := bids[i].SlotNum
|
||||
slot := newSlotAPI(slotNum, currentBlockNum, &bids[i], auctionVars)
|
||||
if order == historydb.OrderAsc {
|
||||
if slot.ItemID >= int(*fromItem) {
|
||||
if slot.ItemID >= uint64(*fromItem) {
|
||||
slots = append(slots, slot)
|
||||
}
|
||||
} else {
|
||||
if slot.ItemID <= int(*fromItem) {
|
||||
if slot.ItemID <= uint64(*fromItem) {
|
||||
slots = append(slots, slot)
|
||||
}
|
||||
}
|
||||
@@ -95,11 +95,11 @@ func newSlotsAPIFromWinnerBids(fromItem *uint, order string, bids []historydb.Bi
|
||||
func addEmptySlot(slots []SlotAPI, slotNum int64, currentBlockNum int64, auctionVars *common.AuctionVariables, fromItem *uint, order string) ([]SlotAPI, error) {
|
||||
emptySlot := newSlotAPI(slotNum, currentBlockNum, nil, auctionVars)
|
||||
if order == historydb.OrderAsc {
|
||||
if emptySlot.ItemID >= int(*fromItem) {
|
||||
if emptySlot.ItemID >= uint64(*fromItem) {
|
||||
slots = append(slots, emptySlot)
|
||||
}
|
||||
} else {
|
||||
if emptySlot.ItemID <= int(*fromItem) {
|
||||
if emptySlot.ItemID <= uint64(*fromItem) {
|
||||
slots = append([]SlotAPI{emptySlot}, slots...)
|
||||
}
|
||||
}
|
||||
@@ -263,7 +263,7 @@ func getSlots(c *gin.Context) {
|
||||
var slotMinLim, slotMaxLim int64
|
||||
var bids []historydb.BidAPI
|
||||
var pag *db.Pagination
|
||||
totalItems := 0
|
||||
totalItems := uint64(0)
|
||||
if wonByEthereumAddress == nil {
|
||||
slotMinLim, slotMaxLim = getLimits(minSlotNum, maxSlotNum, fromItem, limit, order)
|
||||
// Get best bids in range maxSlotNum - minSlotNum
|
||||
@@ -272,7 +272,7 @@ func getSlots(c *gin.Context) {
|
||||
retSQLErr(err, c)
|
||||
return
|
||||
}
|
||||
totalItems = int(*maxSlotNum) - int(*minSlotNum) + 1
|
||||
totalItems = uint64(*maxSlotNum) - uint64(*minSlotNum) + 1
|
||||
} else {
|
||||
slotMinLim, slotMaxLim = getLimitsWithAddr(minSlotNum, maxSlotNum, fromItem, limit, order)
|
||||
bids, pag, err = h.GetBestBidsAPI(&slotMinLim, &slotMaxLim, wonByEthereumAddress, limit, order)
|
||||
@@ -281,7 +281,7 @@ func getSlots(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
if len(bids) > 0 {
|
||||
totalItems = pag.TotalItems
|
||||
totalItems = uint64(pag.TotalItems)
|
||||
*maxSlotNum = int64(pag.LastItem)
|
||||
*minSlotNum = int64(pag.FirstItem)
|
||||
}
|
||||
@@ -306,11 +306,11 @@ func getSlots(c *gin.Context) {
|
||||
if slotsBids[j].SlotNum == i {
|
||||
found = true
|
||||
if order == historydb.OrderAsc {
|
||||
if slotsBids[j].ItemID >= int(*fromItem) {
|
||||
if slotsBids[j].ItemID >= uint64(*fromItem) {
|
||||
slots = append(slots, slotsBids[j])
|
||||
}
|
||||
} else {
|
||||
if slotsBids[j].ItemID <= int(*fromItem) {
|
||||
if slotsBids[j].ItemID <= uint64(*fromItem) {
|
||||
slots = append([]SlotAPI{slotsBids[j]}, slots...)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,11 +28,11 @@ type testSlotsResponse struct {
|
||||
|
||||
func (t testSlotsResponse) GetPagination() *db.Pagination {
|
||||
if t.Slots[0].ItemID < t.Slots[len(t.Slots)-1].ItemID {
|
||||
t.Pagination.FirstReturnedItem = int(t.Slots[0].ItemID)
|
||||
t.Pagination.LastReturnedItem = int(t.Slots[len(t.Slots)-1].ItemID)
|
||||
t.Pagination.FirstReturnedItem = uint64(t.Slots[0].ItemID)
|
||||
t.Pagination.LastReturnedItem = uint64(t.Slots[len(t.Slots)-1].ItemID)
|
||||
} else {
|
||||
t.Pagination.LastReturnedItem = int(t.Slots[0].ItemID)
|
||||
t.Pagination.FirstReturnedItem = int(t.Slots[len(t.Slots)-1].ItemID)
|
||||
t.Pagination.LastReturnedItem = uint64(t.Slots[0].ItemID)
|
||||
t.Pagination.FirstReturnedItem = uint64(t.Slots[len(t.Slots)-1].ItemID)
|
||||
}
|
||||
return t.Pagination
|
||||
}
|
||||
|
||||
@@ -2488,11 +2488,11 @@ components:
|
||||
withdrawalDelay:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/EthBlockNum'
|
||||
- description: The time that anyone needs to wait until a withdrawal of the funds is allowed, in Ethereum blocks.
|
||||
- description: The time that anyone needs to wait until a withdrawal of the funds is allowed, in seconds.
|
||||
- example: 539573849
|
||||
emergencyModeStartingTime:
|
||||
type: integer
|
||||
description: Ethereum block in which the emergency mode will be activated.
|
||||
description: Second (since unix epoch) in which the emergency mode has been activated.
|
||||
example: 10
|
||||
emergencyMode:
|
||||
type: boolean
|
||||
@@ -2716,11 +2716,11 @@ components:
|
||||
properties:
|
||||
maxWithdrawalDelay:
|
||||
type: integer
|
||||
description: Maximum time delay in which the tokens can be locked in the contract. Time is measured in Ethereum blocks.
|
||||
description: Maximum time delay in which the tokens can be locked in the contract. Time is measured in seconds.
|
||||
example: 200
|
||||
maxEmergencyModeTime:
|
||||
type: integer
|
||||
description: Maximum amount of time in which the contract can be in emergency mode. Time is measured in Ethereum blocks.
|
||||
description: Maximum amount of time in which the contract can be in emergency mode. Time is measured in seconds.
|
||||
example: 2000
|
||||
hermezRollup:
|
||||
allOf:
|
||||
|
||||
@@ -34,7 +34,7 @@ type testL2Info struct {
|
||||
type testTx struct {
|
||||
IsL1 string `json:"L1orL2"`
|
||||
TxID common.TxID `json:"id"`
|
||||
ItemID int `json:"itemId"`
|
||||
ItemID uint64 `json:"itemId"`
|
||||
Type common.TxType `json:"type"`
|
||||
Position int `json:"position"`
|
||||
FromIdx *string `json:"fromAccountIndex"`
|
||||
|
||||
Reference in New Issue
Block a user