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
b479cbf5
Commit
b479cbf5
authored
May 14, 2024
by
贾浩@五瓣科技
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update api
parent
e52d8129
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
4 deletions
+24
-4
api.go
api/api.go
+16
-1
router.go
api/router.go
+5
-0
validator.go
core/validator.go
+1
-1
readme.md
readme.md
+2
-2
No files found.
api/api.go
View file @
b479cbf5
...
@@ -34,7 +34,7 @@ func getWorkload(c *gin.Context) {
...
@@ -34,7 +34,7 @@ func getWorkload(c *gin.Context) {
return
return
}
}
utcNow
:=
time
.
Now
()
.
UTC
()
utcNow
:=
time
.
Now
()
.
UTC
()
if
t
.
After
(
time
.
Date
(
utcNow
.
Year
(),
utcNow
.
Month
(),
utcNow
.
Day
(),
0
,
0
,
0
,
0
,
time
.
UTC
))
{
if
t
.
After
(
time
.
Date
(
utcNow
.
Year
(),
utcNow
.
Month
(),
utcNow
.
Day
(),
0
,
0
,
0
,
0
,
time
.
UTC
)
.
Add
(
time
.
Hour
*
24
)
)
{
c
.
JSON
(
200
,
withError
(
DateOutOfRange
))
c
.
JSON
(
200
,
withError
(
DateOutOfRange
))
return
return
}
}
...
@@ -110,6 +110,21 @@ func getRecord(c *gin.Context) {
...
@@ -110,6 +110,21 @@ func getRecord(c *gin.Context) {
c
.
Data
(
200
,
"application/json"
,
data
)
c
.
Data
(
200
,
"application/json"
,
data
)
}
}
func
getWithdrawProof
(
c
*
gin
.
Context
)
{
address
:=
c
.
Query
(
"address"
)
if
!
common
.
IsHexAddress
(
address
)
||
len
(
address
)
!=
42
{
c
.
JSON
(
200
,
withError
(
InvalidParams
))
return
}
amount
,
proofs
:=
validator
.
GetMerkleProof
(
common
.
HexToAddress
(
address
),
""
)
c
.
JSON
(
200
,
withSuccess
(
gin
.
H
{
"amount"
:
amount
,
"proofs"
:
proofs
,
}))
}
func
withSuccess
(
data
interface
{})
interface
{}
{
func
withSuccess
(
data
interface
{})
interface
{}
{
return
map
[
string
]
interface
{}{
return
map
[
string
]
interface
{}{
"code"
:
0
,
"code"
:
0
,
...
...
api/router.go
View file @
b479cbf5
...
@@ -9,4 +9,9 @@ func initRouter(engine *gin.Engine) {
...
@@ -9,4 +9,9 @@ func initRouter(engine *gin.Engine) {
g
.
POST
(
"/workload"
,
getWorkload
)
g
.
POST
(
"/workload"
,
getWorkload
)
g
.
POST
(
"/reward"
,
getReward
)
g
.
POST
(
"/reward"
,
getReward
)
g
.
POST
(
"/record"
,
getRecord
)
g
.
POST
(
"/record"
,
getRecord
)
proof
:=
g
.
Group
(
"/proof"
)
{
proof
.
POST
(
"/withdraw"
,
getWithdrawProof
)
}
}
}
\ No newline at end of file
core/validator.go
View file @
b479cbf5
...
@@ -67,7 +67,7 @@ func RunValidator(q *quest.Quest, cfg *conf.Config) *Validator {
...
@@ -67,7 +67,7 @@ func RunValidator(q *quest.Quest, cfg *conf.Config) *Validator {
<-
time
.
After
(
time
.
Second
*
3
)
<-
time
.
After
(
time
.
Second
*
3
)
if
v
.
date
!=
""
{
if
v
.
date
!=
""
{
// 当前5号,假设db 1号
// 当前5号,假设db 1号
// v.date = 1
, 2,需要处理的是 2,
3号
// v.date = 1
或2时,需要处理的是 2或
3号
for
v
.
dateToTimestamp
(
v
.
date
)
<
v
.
yesterdayTimestamp
()
-
86400
{
for
v
.
dateToTimestamp
(
v
.
date
)
<
v
.
yesterdayTimestamp
()
-
86400
{
if
err
=
v
.
SyncDayJob
(
v
.
dateToTimestamp
(
v
.
date
)
+
86400
,
true
);
err
!=
nil
{
if
err
=
v
.
SyncDayJob
(
v
.
dateToTimestamp
(
v
.
date
)
+
86400
,
true
);
err
!=
nil
{
return
nil
return
nil
...
...
readme.md
View file @
b479cbf5
# Validator for AIGIC
# Validator for AIGIC
定时扫描昨天(UTC+0)的任务,验证签名,写入statedb,将昨日工作量/奖励生成merkle sum tree,将历史总奖励生成merkle tree,提交到合约
## leveldb kv
## leveldb kv
merkle sum tree:
merkle sum tree:
...
@@ -27,4 +28,3 @@ state:
...
@@ -27,4 +28,3 @@ state:
sroot:2020-01-01 -> root(32bytes)
sroot:2020-01-01 -> root(32bytes)
txid:2020-0101 -> txhash(32bytes)
txid:2020-0101 -> txhash(32bytes)
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