Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
validator
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
Odysseus
validator
Commits
82884287
Commit
82884287
authored
Mar 13, 2024
by
贾浩@五瓣科技
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update db config
parent
7c4ee096
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
4 deletions
+8
-4
config.go
conf/config.go
+1
-0
db.go
quest/db.go
+7
-4
No files found.
conf/config.go
View file @
82884287
...
...
@@ -20,4 +20,5 @@ type QuestConfig struct {
User
string
Password
string
Database
string
Debug
bool
}
quest/db.go
View file @
82884287
...
...
@@ -19,6 +19,9 @@ func NewQuest(cfg *conf.QuestConfig) (q *Quest) {
if
err
!=
nil
{
panic
(
err
)
}
if
cfg
.
Debug
{
_db
=
_db
.
Debug
()
}
testSQL
:=
"SELECT 1;"
err
=
_db
.
Raw
(
testSQL
)
.
Error
if
err
!=
nil
{
...
...
@@ -37,7 +40,7 @@ func (q *Quest) GetProofs(startTimestamp, endTimestamp int64, lastTaskID string,
"ORDER BY `TaskId` ASC "
+
"LIMIT ?;"
err
=
q
.
db
.
Debug
()
.
Raw
(
querySQL
,
startTimestamp
,
endTimestamp
,
lastTaskID
,
limit
)
.
Scan
(
&
proofs
)
.
Error
err
=
q
.
db
.
Raw
(
querySQL
,
startTimestamp
,
endTimestamp
,
lastTaskID
,
limit
)
.
Scan
(
&
proofs
)
.
Error
return
}
...
...
@@ -49,7 +52,7 @@ func (q *Quest) GetPendingWorkload(startTimestamp int64, address string) (worklo
"WHERE `TaskFinishTimestamp` >= ?"
+
"AND `TaskProfitAccount` = ? ;"
err
=
q
.
db
.
Debug
()
.
Raw
(
querySQL
,
startTimestamp
,
address
)
.
First
(
&
proof
)
.
Error
err
=
q
.
db
.
Raw
(
querySQL
,
startTimestamp
,
address
)
.
First
(
&
proof
)
.
Error
if
err
!=
nil
{
if
err
==
gorm
.
ErrRecordNotFound
{
return
0
,
nil
...
...
@@ -63,7 +66,7 @@ func (q *Quest) GetGlobalWorkload(startTimestamp int64) (workload uint64, err er
querySQL
:=
"SELECT "
+
"SUM(`TaskWorkload`) "
+
"FROM `proof` "
+
"WHERE `TaskFinishTimestamp` >= ? ;"
err
=
q
.
db
.
Debug
()
.
Raw
(
querySQL
,
startTimestamp
)
.
Row
()
.
Scan
(
&
workload
)
"WHERE `TaskFinishTimestamp` >= ?
AND `TaskFinishTimestamp` < ?
;"
err
=
q
.
db
.
Raw
(
querySQL
,
startTimestamp
,
startTimestamp
+
86400
)
.
Row
()
.
Scan
(
&
workload
)
return
workload
,
err
}
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