Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
chain33-pai
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ligaishun
chain33-pai
Commits
a4447955
Commit
a4447955
authored
Oct 09, 2019
by
szh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update model
parent
ca7c6f7b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
12 deletions
+20
-12
miner.go
miner/miner.go
+10
-1
raspConfig.go
models/raspConfig.go
+10
-11
No files found.
miner/miner.go
View file @
a4447955
...
...
@@ -8,12 +8,21 @@ import (
"time"
"github.com/33cn/chain33/types"
ttype
"github.com/33cn/plugin/plugin/dapp/ticket/types"
"github.com/jinzhu/gorm"
)
func
init
()
{
height
,
err
:=
models
.
GetHeight
()
if
err
!=
nil
{
panic
(
err
)
if
err
==
gorm
.
ErrRecordNotFound
{
err
=
models
.
InitHeight
()
if
err
!=
nil
{
panic
(
err
)
}
}
else
{
panic
(
err
)
}
}
prev
.
LocalHeight
=
height
prev
.
SetMainHeight
()
...
...
models/raspConfig.go
View file @
a4447955
package
models
import
(
"github.com/jinzhu/gorm"
)
type
RaspConfig
struct
{
Model
Height
int64
`json:"height"`
...
...
@@ -11,12 +7,15 @@ type RaspConfig struct {
// GetHeight get lastheight in chain33
func
GetHeight
()
(
int64
,
error
)
{
var
raspConfig
RaspConfig
err
:=
db
.
Select
(
"height"
)
.
First
(
&
raspConfig
)
.
Error
if
err
!=
nil
&&
err
!=
gorm
.
ErrRecordNotFound
{
return
0
,
err
var
list
[]
*
RaspConfig
err
:=
db
.
Find
(
&
list
)
.
Error
if
err
!=
nil
{
//if err == gorm.ErrRecordNotFound {
// return 0, err
//}
return
0
,
err
}
return
raspConfig
.
Height
,
nil
return
list
[
0
]
.
Height
,
nil
}
// EditArticle modify a single article
...
...
@@ -29,9 +28,9 @@ func UpdateHeight(height int64) error {
}
// AddArticle add a single article
func
InitHeight
(
data
map
[
string
]
interface
{}
)
error
{
func
InitHeight
()
error
{
config
:=
RaspConfig
{
Height
:
data
[
"height"
]
.
(
int64
)
,
Height
:
0
,
}
if
err
:=
db
.
Create
(
&
config
)
.
Error
;
err
!=
nil
{
return
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