Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
aa2c6d38
Commit
aa2c6d38
authored
Apr 02, 2019
by
liuyuhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
2fff13bc
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
168 additions
and
9 deletions
+168
-9
round_state.go
plugin/consensus/tendermint/types/round_state.go
+3
-3
certutils.go
...rt/authority/tools/cryptogen/generator/utils/certutils.go
+6
-6
blockstore_test.go
vendor/github.com/33cn/chain33/blockchain/blockstore_test.go
+36
-0
restore.go
vendor/github.com/33cn/chain33/blockchain/restore.go
+104
-0
ticket.go
...hub.com/33cn/chain33/system/store/mavl/db/types/ticket.go
+19
-0
ticket.pb.go
....com/33cn/chain33/system/store/mavl/db/types/ticket.pb.go
+0
-0
No files found.
plugin/consensus/tendermint/types/round_state.go
View file @
aa2c6d38
...
...
@@ -117,9 +117,9 @@ type RoundState struct {
// RoundStateMessage ...
func
(
rs
*
RoundState
)
RoundStateMessage
()
*
tmtypes
.
NewRoundStepMsg
{
return
&
tmtypes
.
NewRoundStepMsg
{
Height
:
rs
.
Height
,
Round
:
int32
(
rs
.
Round
),
Step
:
int32
(
rs
.
Step
),
Height
:
rs
.
Height
,
Round
:
int32
(
rs
.
Round
),
Step
:
int32
(
rs
.
Step
),
SecondsSinceStartTime
:
int32
(
time
.
Since
(
rs
.
StartTime
)
.
Seconds
()),
LastCommitRound
:
int32
(
rs
.
LastCommit
.
Round
()),
}
...
...
plugin/dapp/cert/authority/tools/cryptogen/generator/utils/certutils.go
View file @
aa2c6d38
...
...
@@ -73,9 +73,9 @@ func ParseX509CertificateToSm2(x509Cert *x509.Certificate) *sm2.Certificate {
UnknownExtKeyUsage
:
x509Cert
.
UnknownExtKeyUsage
,
BasicConstraintsValid
:
x509Cert
.
BasicConstraintsValid
,
IsCA
:
x509Cert
.
IsCA
,
MaxPathLen
:
x509Cert
.
MaxPathLen
,
MaxPathLenZero
:
x509Cert
.
MaxPathLenZero
,
IsCA
:
x509Cert
.
IsCA
,
MaxPathLen
:
x509Cert
.
MaxPathLen
,
MaxPathLenZero
:
x509Cert
.
MaxPathLenZero
,
SubjectKeyId
:
x509Cert
.
SubjectKeyId
,
AuthorityKeyId
:
x509Cert
.
AuthorityKeyId
,
...
...
@@ -136,9 +136,9 @@ func ParseSm2CertificateToX509(sm2Cert *sm2.Certificate) *x509.Certificate {
UnknownExtKeyUsage
:
sm2Cert
.
UnknownExtKeyUsage
,
BasicConstraintsValid
:
sm2Cert
.
BasicConstraintsValid
,
IsCA
:
sm2Cert
.
IsCA
,
MaxPathLen
:
sm2Cert
.
MaxPathLen
,
MaxPathLenZero
:
sm2Cert
.
MaxPathLenZero
,
IsCA
:
sm2Cert
.
IsCA
,
MaxPathLen
:
sm2Cert
.
MaxPathLen
,
MaxPathLenZero
:
sm2Cert
.
MaxPathLenZero
,
SubjectKeyId
:
sm2Cert
.
SubjectKeyId
,
AuthorityKeyId
:
sm2Cert
.
AuthorityKeyId
,
...
...
vendor/github.com/33cn/chain33/blockchain/blockstore_test.go
0 → 100644
View file @
aa2c6d38
package
blockchain_test
import
(
"testing"
"io/ioutil"
"os"
"github.com/33cn/chain33/blockchain"
dbm
"github.com/33cn/chain33/common/db"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func
TestGetStoreUpgradeMeta
(
t
*
testing
.
T
)
{
dir
,
err
:=
ioutil
.
TempDir
(
""
,
"example"
)
assert
.
Nil
(
t
,
err
)
defer
os
.
RemoveAll
(
dir
)
// clean up
os
.
RemoveAll
(
dir
)
//删除已存在目录
blockStoreDB
:=
dbm
.
NewDB
(
"blockchain"
,
"leveldb"
,
dir
,
100
)
blockStore
:=
blockchain
.
NewBlockStore
(
nil
,
blockStoreDB
,
nil
)
require
.
NotNil
(
t
,
blockStore
)
meta
,
err
:=
blockStore
.
GetStoreUpgradeMeta
()
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
meta
.
Version
,
"0.0.0"
)
meta
.
Version
=
"1.0.0"
err
=
blockStore
.
SetStoreUpgradeMeta
(
meta
)
require
.
NoError
(
t
,
err
)
meta
,
err
=
blockStore
.
GetStoreUpgradeMeta
()
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
meta
.
Version
,
"1.0.0"
)
}
vendor/github.com/33cn/chain33/blockchain/restore.go
0 → 100644
View file @
aa2c6d38
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
blockchain
import
(
"strings"
"fmt"
"github.com/33cn/chain33/common/version"
"github.com/33cn/chain33/types"
)
// Upgrade 升级localDB和storeDB
func
(
chain
*
BlockChain
)
Upgrade
()
{
chain
.
UpgradeChain
()
chain
.
UpgradeStore
()
}
//UpgradeStore 升级storedb
func
(
chain
*
BlockChain
)
UpgradeStore
()
{
meta
,
err
:=
chain
.
blockStore
.
GetStoreUpgradeMeta
()
if
err
!=
nil
{
panic
(
err
)
}
curheight
:=
chain
.
GetBlockHeight
()
if
curheight
==
-
1
{
meta
=
&
types
.
UpgradeMeta
{
Version
:
version
.
GetStoreDBVersion
(),
}
err
=
chain
.
blockStore
.
SetStoreUpgradeMeta
(
meta
)
if
err
!=
nil
{
panic
(
err
)
}
}
if
chain
.
needReExec
(
meta
)
{
start
:=
meta
.
Height
//reExecBlock 的过程中,会每个高度都去更新meta
chain
.
ReExecBlock
(
start
,
curheight
)
meta
:=
&
types
.
UpgradeMeta
{
Starting
:
false
,
Version
:
version
.
GetStoreDBVersion
(),
Height
:
0
,
}
err
=
chain
.
blockStore
.
SetStoreUpgradeMeta
(
meta
)
if
err
!=
nil
{
panic
(
err
)
}
}
}
// ReExecBlock 从对应高度本地重新执行区块
func
(
chain
*
BlockChain
)
ReExecBlock
(
startHeight
,
curHeight
int64
)
{
var
prevStateHash
[]
byte
if
startHeight
>
0
{
blockdetail
,
err
:=
chain
.
GetBlock
(
startHeight
-
1
)
if
err
!=
nil
{
panic
(
fmt
.
Sprintf
(
"get height=%d err, this not allow fail"
,
startHeight
-
1
))
}
prevStateHash
=
blockdetail
.
Block
.
StateHash
}
for
i
:=
startHeight
;
i
<=
curHeight
;
i
++
{
blockdetail
,
err
:=
chain
.
GetBlock
(
i
)
if
err
!=
nil
{
panic
(
fmt
.
Sprintf
(
"get height=%d err, this not allow fail"
,
i
))
}
block
:=
blockdetail
.
Block
err
=
execBlockUpgrade
(
chain
.
client
,
prevStateHash
,
block
,
false
)
if
err
!=
nil
{
panic
(
fmt
.
Sprintf
(
"execBlockEx height=%d err=%s, this not allow fail"
,
i
,
err
.
Error
()))
}
prevStateHash
=
block
.
StateHash
//更新高度
err
=
chain
.
upgradeMeta
(
startHeight
)
if
err
!=
nil
{
panic
(
err
)
}
}
}
func
(
chain
*
BlockChain
)
needReExec
(
meta
*
types
.
UpgradeMeta
)
bool
{
if
meta
.
Starting
{
//正在
return
true
}
v1
:=
meta
.
Version
v2
:=
version
.
GetStoreDBVersion
()
v1arr
:=
strings
.
Split
(
v1
,
"."
)
v2arr
:=
strings
.
Split
(
v2
,
"."
)
if
len
(
v1arr
)
!=
3
||
len
(
v2arr
)
!=
3
{
panic
(
"upgrade store meta version error"
)
}
return
v1arr
[
0
]
!=
v2arr
[
0
]
}
func
(
chain
*
BlockChain
)
upgradeMeta
(
height
int64
)
error
{
meta
:=
&
types
.
UpgradeMeta
{
Starting
:
true
,
Version
:
version
.
GetStoreDBVersion
(),
Height
:
height
+
1
,
}
return
chain
.
blockStore
.
SetStoreUpgradeMeta
(
meta
)
}
vendor/github.com/33cn/chain33/system/store/mavl/db/types/ticket.go
0 → 100755
View file @
aa2c6d38
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
types
var
(
// TicketPrefix ticket prefix
TicketPrefix
=
[]
byte
(
"mavl-ticket-"
)
)
const
(
// StatusNewTicket new ticket status
StatusNewTicket
=
1
// StatusMinerTicket Miner ticket status
StatusMinerTicket
=
2
// StatusCloseTicket Close ticket status
StatusCloseTicket
=
3
)
vendor/github.com/33cn/chain33/system/store/mavl/db/types/ticket.pb.go
0 → 100644
View file @
aa2c6d38
This diff is collapsed.
Click to expand it.
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