mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 11:26:44 +01:00
Add missing error handling
This commit is contained in:
@@ -958,7 +958,9 @@ var (
|
|||||||
logHEZClaimed = crypto.Keccak256Hash([]byte("HEZClaimed(address,uint128)"))
|
logHEZClaimed = crypto.Keccak256Hash([]byte("HEZClaimed(address,uint128)"))
|
||||||
)
|
)
|
||||||
|
|
||||||
// AuctionEventsByBlock returns the events in a block that happened in the Auction Smart Contract
|
// AuctionEventsByBlock returns the events in a block that happened in the
|
||||||
|
// Auction Smart Contract and the blockHash where the eents happened. If there
|
||||||
|
// are no events in that block, blockHash is nil.
|
||||||
func (c *AuctionClient) AuctionEventsByBlock(blockNum int64) (*AuctionEvents, *ethCommon.Hash, error) {
|
func (c *AuctionClient) AuctionEventsByBlock(blockNum int64) (*AuctionEvents, *ethCommon.Hash, error) {
|
||||||
var auctionEvents AuctionEvents
|
var auctionEvents AuctionEvents
|
||||||
var blockHash ethCommon.Hash
|
var blockHash ethCommon.Hash
|
||||||
@@ -974,14 +976,14 @@ func (c *AuctionClient) AuctionEventsByBlock(blockNum int64) (*AuctionEvents, *e
|
|||||||
|
|
||||||
logs, err := c.client.client.FilterLogs(context.TODO(), query)
|
logs, err := c.client.client.FilterLogs(context.TODO(), query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
if len(logs) > 0 {
|
if len(logs) > 0 {
|
||||||
blockHash = logs[0].BlockHash
|
blockHash = logs[0].BlockHash
|
||||||
}
|
}
|
||||||
for _, vLog := range logs {
|
for _, vLog := range logs {
|
||||||
if vLog.BlockHash != blockHash {
|
if vLog.BlockHash != blockHash {
|
||||||
return nil, nil, err
|
return nil, nil, ErrBlockHashMismatchEvent
|
||||||
}
|
}
|
||||||
switch vLog.Topics[0] {
|
switch vLog.Topics[0] {
|
||||||
case logNewBid:
|
case logNewBid:
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ var (
|
|||||||
ErrReceiptStatusFailed = fmt.Errorf("receipt status is failed")
|
ErrReceiptStatusFailed = fmt.Errorf("receipt status is failed")
|
||||||
// ErrReceiptNotReceived is used when unable to retrieve a transaction
|
// ErrReceiptNotReceived is used when unable to retrieve a transaction
|
||||||
ErrReceiptNotReceived = fmt.Errorf("receipt not available")
|
ErrReceiptNotReceived = fmt.Errorf("receipt not available")
|
||||||
|
// ErrBlockHashMismatchEvent is used when there's a block hash mismatch
|
||||||
|
// beetween different events of the same block
|
||||||
|
ErrBlockHashMismatchEvent = fmt.Errorf("block hash mismatch in event log")
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@@ -126,9 +126,15 @@ func TestMain(m *testing.M) {
|
|||||||
// Controllable Governance Address
|
// Controllable Governance Address
|
||||||
|
|
||||||
ethereumClientGov := NewEthereumClient(ethClient, accountGov, ks, nil)
|
ethereumClientGov := NewEthereumClient(ethClient, accountGov, ks, nil)
|
||||||
auctionClient, _ = NewAuctionClient(ethereumClientGov, auctionAddressConst, tokenHezAddressConst)
|
auctionClient, err = NewAuctionClient(ethereumClientGov, auctionAddressConst, tokenHezAddressConst)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
rollupClient = NewRollupClient(ethereumClientGov, hermezRollupAddressConst)
|
rollupClient = NewRollupClient(ethereumClientGov, hermezRollupAddressConst)
|
||||||
wdelayerClient, _ = NewWDelayerClient(ethereumClientGov, wdelayerAddressConst)
|
wdelayerClient, err = NewWDelayerClient(ethereumClientGov, wdelayerAddressConst)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
ethereumClientKep = NewEthereumClient(ethClient, accountKep, ks, nil)
|
ethereumClientKep = NewEthereumClient(ethClient, accountKep, ks, nil)
|
||||||
ethereumClientWhite = NewEthereumClient(ethClient, accountWhite, ks, nil)
|
ethereumClientWhite = NewEthereumClient(ethClient, accountWhite, ks, nil)
|
||||||
|
|||||||
@@ -430,7 +430,9 @@ var (
|
|||||||
logNewHermezGovernanceDAOAddress = crypto.Keccak256Hash([]byte("NewHermezGovernanceDAOAddress(address)"))
|
logNewHermezGovernanceDAOAddress = crypto.Keccak256Hash([]byte("NewHermezGovernanceDAOAddress(address)"))
|
||||||
)
|
)
|
||||||
|
|
||||||
// WDelayerEventsByBlock returns the events in a block that happened in the WDelayer Smart Contract
|
// WDelayerEventsByBlock returns the events in a block that happened in the
|
||||||
|
// WDelayer Smart Contract and the blockHash where the eents happened. If
|
||||||
|
// there are no events in that block, blockHash is nil.
|
||||||
func (c *WDelayerClient) WDelayerEventsByBlock(blockNum int64) (*WDelayerEvents, *ethCommon.Hash, error) {
|
func (c *WDelayerClient) WDelayerEventsByBlock(blockNum int64) (*WDelayerEvents, *ethCommon.Hash, error) {
|
||||||
var wdelayerEvents WDelayerEvents
|
var wdelayerEvents WDelayerEvents
|
||||||
var blockHash ethCommon.Hash
|
var blockHash ethCommon.Hash
|
||||||
@@ -447,14 +449,14 @@ func (c *WDelayerClient) WDelayerEventsByBlock(blockNum int64) (*WDelayerEvents,
|
|||||||
|
|
||||||
logs, err := c.client.client.FilterLogs(context.Background(), query)
|
logs, err := c.client.client.FilterLogs(context.Background(), query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
if len(logs) > 0 {
|
if len(logs) > 0 {
|
||||||
blockHash = logs[0].BlockHash
|
blockHash = logs[0].BlockHash
|
||||||
}
|
}
|
||||||
for _, vLog := range logs {
|
for _, vLog := range logs {
|
||||||
if vLog.BlockHash != blockHash {
|
if vLog.BlockHash != blockHash {
|
||||||
return nil, nil, err
|
return nil, nil, ErrBlockHashMismatchEvent
|
||||||
}
|
}
|
||||||
switch vLog.Topics[0] {
|
switch vLog.Topics[0] {
|
||||||
case logDeposit:
|
case logDeposit:
|
||||||
|
|||||||
Reference in New Issue
Block a user