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
59ff146c
Unverified
Commit
59ff146c
authored
Feb 24, 2022
by
Conner Fromknecht
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: use uint64 for deposit ids and block numbers
Less casting.
parent
6af67df5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
13 deletions
+13
-13
db.go
go/teleportr/db/db.go
+9
-9
db_test.go
go/teleportr/db/db_test.go
+4
-4
No files found.
go/teleportr/db/db.go
View file @
59ff146c
...
...
@@ -24,9 +24,9 @@ var (
// Deposit represents an event emitted from the TeleportrDeposit contract on L1,
// along with additional info about the tx that generated the event.
type
Deposit
struct
{
ID
int64
ID
u
int64
TxnHash
common
.
Hash
BlockNumber
int64
BlockNumber
u
int64
BlockTimestamp
time
.
Time
Address
common
.
Address
Amount
*
big
.
Int
...
...
@@ -35,14 +35,14 @@ type Deposit struct {
// ConfirmationInfo holds metadata about a tx on either the L1 or L2 chain.
type
ConfirmationInfo
struct
{
TxnHash
common
.
Hash
BlockNumber
int64
BlockNumber
u
int64
BlockTimestamp
time
.
Time
}
// CompletedTeleport represents an L1 deposit that has been disbursed on L2. The
// struct also hold info about the L1 and L2 txns involved.
type
CompletedTeleport
struct
{
ID
int64
ID
u
int64
Address
common
.
Address
Amount
*
big
.
Int
Deposit
ConfirmationInfo
...
...
@@ -211,10 +211,10 @@ LIMIT 1
// LatestDeposit returns the block number of the latest deposit known to the
// database.
func
(
d
*
Database
)
LatestDeposit
()
(
*
int64
,
error
)
{
func
(
d
*
Database
)
LatestDeposit
()
(
*
u
int64
,
error
)
{
row
:=
d
.
conn
.
QueryRow
(
latestDepositQuery
)
var
latestTransfer
int64
var
latestTransfer
u
int64
err
:=
row
.
Scan
(
&
latestTransfer
)
if
err
==
sql
.
ErrNoRows
{
return
nil
,
nil
...
...
@@ -235,7 +235,7 @@ ORDER BY dep.id ASC
// ConfirmedDeposits returns the set of all deposits that have sufficient
// confirmation, but do not have a recorded disbursement.
func
(
d
*
Database
)
ConfirmedDeposits
(
blockNumber
,
confirmations
int64
)
([]
Deposit
,
error
)
{
func
(
d
*
Database
)
ConfirmedDeposits
(
blockNumber
,
confirmations
u
int64
)
([]
Deposit
,
error
)
{
rows
,
err
:=
d
.
conn
.
Query
(
confirmedDepositsQuery
,
confirmations
,
blockNumber
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -287,9 +287,9 @@ SET (txn_hash, block_number, block_timestamp) = ($2, $3, $4)
// UpsertDisbursement inserts a disbursement, or updates an existing record
// in-place if the ID already exists.
func
(
d
*
Database
)
UpsertDisbursement
(
id
int64
,
id
u
int64
,
txnHash
common
.
Hash
,
blockNumber
int64
,
blockNumber
u
int64
,
blockTimestamp
time
.
Time
,
)
error
{
if
blockTimestamp
.
IsZero
()
{
...
...
go/teleportr/db/db_test.go
View file @
59ff146c
...
...
@@ -93,10 +93,10 @@ func TestLatestDeposit(t *testing.T) {
// Query should return nil on empty databse.
latestDeposit
,
err
:=
d
.
LatestDeposit
()
require
.
Nil
(
t
,
err
)
require
.
Equal
(
t
,
(
*
int64
)(
nil
),
latestDeposit
)
require
.
Equal
(
t
,
(
*
u
int64
)(
nil
),
latestDeposit
)
// Update table to have a single element.
expLatestDeposit
:=
int64
(
1
)
expLatestDeposit
:=
u
int64
(
1
)
err
=
d
.
UpsertDeposits
([]
db
.
Deposit
{{
ID
:
1
,
TxnHash
:
common
.
HexToHash
(
"0xf1"
),
...
...
@@ -249,9 +249,9 @@ func TestUpsertDisbursement(t *testing.T) {
address
:=
common
.
HexToAddress
(
"0xaa01"
)
amount
:=
big
.
NewInt
(
1
)
depTxnHash
:=
common
.
HexToHash
(
"0xdd01"
)
depBlockNumber
:=
int64
(
1
)
depBlockNumber
:=
u
int64
(
1
)
disTxnHash
:=
common
.
HexToHash
(
"0xee02"
)
disBlockNumber
:=
int64
(
2
)
disBlockNumber
:=
u
int64
(
2
)
// Calling UpsertDisbursement with the zero timestamp should fail.
err
:=
d
.
UpsertDisbursement
(
0
,
common
.
HexToHash
(
"0xdd00"
),
0
,
time
.
Time
{})
...
...
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