Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
15e93514
Commit
15e93514
authored
Jul 10, 2023
by
Hamdi Allam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
utilize pointers for database fields that are nullable than relying on zero-values
parent
c6498472
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
4 deletions
+24
-4
bridge.go
indexer/database/bridge.go
+24
-4
No files found.
indexer/database/bridge.go
View file @
15e93514
...
...
@@ -2,6 +2,7 @@ package database
import
(
"errors"
"fmt"
"math/big"
"gorm.io/gorm"
...
...
@@ -64,8 +65,8 @@ type Withdrawal struct {
SentMessageNonce
U256
WithdrawalHash
common
.
Hash
`gorm:"serializer:json"`
ProvenL1EventGUID
uuid
.
UUID
`gorm:"default:null"`
FinalizedL1EventGUID
uuid
.
UUID
`gorm:"default:null"`
ProvenL1EventGUID
*
uuid
.
UUID
FinalizedL1EventGUID
*
uuid
.
UUID
Tx
Transaction
`gorm:"embedded"`
TokenPair
TokenPair
`gorm:"embedded"`
...
...
@@ -86,6 +87,7 @@ type BridgeView interface {
WithdrawalsByAddress
(
address
common
.
Address
)
([]
*
WithdrawalWithTransactionHashes
,
error
)
WithdrawalByMessageNonce
(
*
big
.
Int
)
(
*
Withdrawal
,
error
)
WithdrawalByHash
(
common
.
Hash
)
(
*
Withdrawal
,
error
)
LatestWithdrawalMessageNonce
()
(
*
big
.
Int
,
error
)
}
...
...
@@ -193,7 +195,7 @@ func (db *bridgeDB) MarkProvenWithdrawalEvent(guid, provenL1EventGuid uuid.UUID)
return
result
.
Error
}
withdrawal
.
ProvenL1EventGUID
=
provenL1EventGuid
withdrawal
.
ProvenL1EventGUID
=
&
provenL1EventGuid
result
=
db
.
gorm
.
Save
(
&
withdrawal
)
return
result
.
Error
}
...
...
@@ -205,7 +207,11 @@ func (db *bridgeDB) MarkFinalizedWithdrawalEvent(guid, finalizedL1EventGuid uuid
return
result
.
Error
}
withdrawal
.
FinalizedL1EventGUID
=
finalizedL1EventGuid
if
withdrawal
.
ProvenL1EventGUID
==
nil
{
return
errors
.
New
(
fmt
.
Sprintf
(
"withdrawal %s marked finalized prior to being proven"
,
guid
))
}
withdrawal
.
FinalizedL1EventGUID
=
&
finalizedL1EventGuid
result
=
db
.
gorm
.
Save
(
&
withdrawal
)
return
result
.
Error
}
...
...
@@ -247,6 +253,20 @@ func (db *bridgeDB) WithdrawalByMessageNonce(nonce *big.Int) (*Withdrawal, error
return
&
withdrawal
,
nil
}
func
(
db
*
bridgeDB
)
WithdrawalByHash
(
hash
common
.
Hash
)
(
*
Withdrawal
,
error
)
{
var
withdrawal
Withdrawal
result
:=
db
.
gorm
.
First
(
&
withdrawal
,
"withdrawal_hash = ?"
,
hash
.
String
())
if
result
.
Error
!=
nil
{
if
errors
.
Is
(
result
.
Error
,
gorm
.
ErrRecordNotFound
)
{
return
nil
,
nil
}
return
nil
,
result
.
Error
}
return
&
withdrawal
,
nil
}
func
(
db
*
bridgeDB
)
LatestWithdrawalMessageNonce
()
(
*
big
.
Int
,
error
)
{
var
withdrawal
Withdrawal
result
:=
db
.
gorm
.
Order
(
"sent_message_nonce DESC"
)
.
Take
(
&
withdrawal
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment