Commit c8eaee6f authored by vipwzw's avatar vipwzw Committed by 33cn

update 04/03

parent 7c5ce435
......@@ -171,7 +171,7 @@ proto:protobuf
protobuf: ## Generate protbuf file of types package
@cd types/proto && ./create_protobuf.sh && cd ../..
@find ./system/dapp -maxdepth 2 -type d -name proto -exec make -C {} \;
@find ./system/dapp ./system/store/mavl -maxdepth 2 -type d -name proto -exec make -C {} \;
depends: ## Generate depends file of types package
@find ./system/dapp -maxdepth 2 -type d -name cmd -exec make -C {} OUT="$(MKDIR)build/ci" FLAG= \;
......
......@@ -1092,6 +1092,31 @@ func (bs *BlockStore) SetUpgradeMeta(meta *types.UpgradeMeta) error {
return bs.db.SetSync(version.LocalDBMeta, verByte)
}
//GetStoreUpgradeMeta 获取存在blockchain中的Store的数据库版本号
func (bs *BlockStore) GetStoreUpgradeMeta() (*types.UpgradeMeta, error) {
ver := types.UpgradeMeta{}
version, err := bs.db.Get(version.StoreDBMeta)
if err != nil && err != dbm.ErrNotFoundInDb {
return nil, err
}
if len(version) == 0 {
return &types.UpgradeMeta{Version: "0.0.0"}, nil
}
err = types.Decode(version, &ver)
if err != nil {
return nil, err
}
storeLog.Info("GetStoreUpgradeMeta", "blockchain db version", ver)
return &ver, nil
}
//SetStoreUpgradeMeta 设置blockchain中的Store的数据库版本号
func (bs *BlockStore) SetStoreUpgradeMeta(meta *types.UpgradeMeta) error {
verByte := types.Encode(meta)
storeLog.Info("SetStoreUpgradeMeta", "meta", meta)
return bs.db.SetSync(version.StoreDBMeta, verByte)
}
//isRecordBlockSequence配置的合法性检测
func (bs *BlockStore) isRecordBlockSequenceValid(chain *BlockChain) {
lastHeight := bs.Height()
......
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")
}
......@@ -128,7 +128,7 @@ func TestBlockChain(t *testing.T) {
testWriteBlockToDbTemp(t, blockchain)
testReadBlockToExec(t, blockchain)
testReExecBlock(t, blockchain)
testReExecBlockMsg(t, mock33, blockchain)
testUpgradeStore(t, blockchain)
}
func testProcAddBlockMsg(t *testing.T, mock33 *testnode.Chain33Mock, blockchain *blockchain.BlockChain) {
......@@ -1115,17 +1115,12 @@ func testWriteBlockToDbTemp(t *testing.T, chain *blockchain.BlockChain) {
func testReExecBlock(t *testing.T, chain *blockchain.BlockChain) {
chainlog.Info("ReExecBlock begin ---------------------")
curheight := chain.GetBlockHeight()
chain.ProcessReExecBlock(0, curheight)
chain.ReExecBlock(0, curheight)
chainlog.Info("ReExecBlock end ---------------------")
}
func testReExecBlockMsg(t *testing.T, mock33 *testnode.Chain33Mock, chain *blockchain.BlockChain) {
var err error
client := mock33.GetClient()
msg1 := client.NewMessage("blockchain", types.EventReExecBlock, &types.ReqInt{Height: 8})
err = client.Send(msg1, true)
require.NoError(t, err)
_, err = client.Wait(msg1)
require.NoError(t, err)
time.Sleep(time.Millisecond * 20)
func testUpgradeStore(t *testing.T, chain *blockchain.BlockChain) {
chainlog.Info("UpgradeStore begin ---------------------")
chain.UpgradeStore()
chainlog.Info("UpgradeStore end ---------------------")
}
......@@ -90,8 +90,6 @@ func (chain *BlockChain) ProcRecvMsg() {
case types.EventGetSeqCBLastNum:
go chain.processMsg(msg, reqnum, chain.getSeqCBLastNum)
case types.EventReExecBlock:
go chain.processMsg(msg, reqnum, chain.reExecBlock)
default:
go chain.processMsg(msg, reqnum, chain.unknowMsg)
}
......@@ -135,17 +133,6 @@ func (chain *BlockChain) getSeqCBLastNum(msg *queue.Message) {
msg.Reply(chain.client.NewMessage("rpc", types.EventGetSeqCBLastNum, lastNum))
}
func (chain *BlockChain) reExecBlock(msg *queue.Message) {
data := (msg.Data).(*types.ReqInt)
curHeight := chain.GetBlockHeight()
if curHeight < data.Height {
msg.Reply(chain.client.NewMessage("store", types.EventReExecBlock, &types.ReplyString{Data: "none"}))
return
}
msg.Reply(chain.client.NewMessage("store", types.EventReExecBlock, &types.ReplyString{Data: "need"}))
chain.ProcessReExecBlock(data.Height, curHeight)
}
func (chain *BlockChain) queryTx(msg *queue.Message) {
txhash := (msg.Data).(*types.ReqHash)
TransactionDetail, err := chain.ProcQueryTxMsg(txhash.Hash)
......
......@@ -10,8 +10,6 @@ import (
"math/big"
"sync/atomic"
"fmt"
"github.com/33cn/chain33/client/api"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common/difficulty"
......@@ -601,40 +599,6 @@ func (b *BlockChain) ProcessDelParaChainBlock(broadcast bool, blockdetail *types
return nil, true, false, nil
}
// ProcessReExecBlock 从对应高度本地重新执行区块
func (b *BlockChain) ProcessReExecBlock(startHeight, curHeight int64) {
var prevStateHash []byte
if startHeight > 0 {
blockdetail, err := b.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 := b.GetBlock(i)
if err != nil {
panic(fmt.Sprintf("get height=%d err, this not allow fail", i))
}
block := blockdetail.Block
err = execBlockUpgrade(b.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
}
// 通知执行结束
msg := b.client.NewMessage("store", types.EventReExecBlock, &types.ReplyString{Data: "over"})
err := b.client.Send(msg, true)
if err != nil {
return
}
_, err = b.client.Wait(msg)
if err != nil {
return
}
}
// IsRecordFaultErr 检测此错误是否要记录到故障错误中
func IsRecordFaultErr(err error) bool {
return err != types.ErrFutureBlock && !api.IsGrpcError(err) && !api.IsQueueError(err)
......
......@@ -29,7 +29,7 @@ func (chain *BlockChain) UpgradeChain() {
}
if chain.needReIndex(meta) {
//如果没有开始重建index,那么先del all keys
if !meta.Indexing {
if !meta.Starting {
chainlog.Info("begin del all keys")
chain.blockStore.delAllKeys()
chainlog.Info("end del all keys")
......@@ -38,7 +38,7 @@ func (chain *BlockChain) UpgradeChain() {
//reindex 的过程中,会每个高度都去更新meta
chain.reIndex(start, curheight)
meta := &types.UpgradeMeta{
Indexing: false,
Starting: false,
Version: version.GetLocalDBVersion(),
Height: 0,
}
......@@ -59,7 +59,7 @@ func (chain *BlockChain) reIndex(start, end int64) {
}
func (chain *BlockChain) needReIndex(meta *types.UpgradeMeta) bool {
if meta.Indexing { //正在index
if meta.Starting { //正在index
return true
}
v1 := meta.Version
......@@ -89,7 +89,7 @@ func (chain *BlockChain) reIndexOne(height int64) error {
panic(err)
}
meta := &types.UpgradeMeta{
Indexing: true,
Starting: true,
Version: version.GetLocalDBVersion(),
Height: height + 1,
}
......
// 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)
}
......@@ -200,8 +200,10 @@ driver="leveldb"
dbPath="datadir/mavltree"
# Cache大小
dbCache=128
# 数据库版本
# local数据库版本
localdbVersion="1.0.0"
# store数据库版本
storedbVersion="1.0.0"
[store.sub.mavl]
# 是否使能mavl加前缀
......
......@@ -12,8 +12,10 @@ var (
WalletVerKey = []byte("WalletVerKey")
BlockChainVerKey = []byte("BlockChainVerKey")
LocalDBMeta = []byte("LocalDBMeta")
StoreDBMeta = []byte("StoreDBMeta")
MavlTreeVerKey = []byte("MavlTreeVerKey")
localversion = "1.0.0"
storeversion = "1.0.0"
appversion = "1.0.0"
GitCommit string
)
......@@ -49,6 +51,22 @@ func SetLocalDBVersion(version string) {
}
}
//GetStoreDBVersion 数据库版本解析
/*
格式: v1.v2.v3
如果: v1 升级了, 那么意味着storedb 需要升级
*/
func GetStoreDBVersion() string {
return storeversion
}
//SetStoreDBVersion 通过设置版本号,强制重建数据库
func SetStoreDBVersion(version string) {
if version != "" {
storeversion = version
}
}
//GetAppVersion 获取应用 app 的版本
func GetAppVersion() string {
return appversion
......
......@@ -12,7 +12,6 @@ func init() {
type feePlugin struct {
pluginBase
fee types.TotalFee
}
func (p *feePlugin) CheckEnable(executor *executor, enable bool) (kvs []*types.KeyValue, ok bool, err error) {
......@@ -20,13 +19,13 @@ func (p *feePlugin) CheckEnable(executor *executor, enable bool) (kvs []*types.K
}
func (p *feePlugin) ExecLocal(executor *executor, data *types.BlockDetail) ([]*types.KeyValue, error) {
p.fee = types.TotalFee{}
fee := &types.TotalFee{}
for i := 0; i < len(data.Block.Txs); i++ {
tx := data.Block.Txs[i]
p.fee.Fee += tx.Fee
p.fee.TxCount++
fee.Fee += tx.Fee
fee.TxCount++
}
kv, err := saveFee(executor, &p.fee, data.Block.ParentHash, data.Block.Hash())
kv, err := saveFee(executor, fee, data.Block.ParentHash, data.Block.Hash())
if err != nil {
return nil, err
}
......
......@@ -284,7 +284,7 @@ func (d *DownloadJob) syncDownloadBlock(peer *Peer, inv *pb.Inventory, bchan cha
RECV:
for _, item := range invdatas.Items {
bchan <- &pb.BlockPid{Pid: peer.GetPeerName(), Block: item.GetBlock()} //下载完成后插入bchan
log.Debug("download", "frompeer", peer.Addr(), "blockheight", inv.GetHeight(), "Blocksize", item.GetBlock().XXX_Size())
log.Debug("download", "frompeer", peer.Addr(), "blockheight", inv.GetHeight(), "Blocksize", item.GetBlock().Size())
}
}
}
......@@ -86,9 +86,6 @@ func (store *BaseStore) SetQueueClient(c queue.Client) {
}
store.done <- struct{}{}
}()
if store.child != nil {
store.child.ProcEvent(nil)
}
}
//Wait wait for basestore ready
......
#!/bin/sh
protoc --go_out=plugins=grpc:../ticket ./*.proto --proto_path=. --proto_path="$GOPATH/src/github.com/33cn/chain33/types/proto/"
syntax = "proto3";
package ticket;
message Ticket {
string ticketId = 1;
// 0 -> 未成熟 1 -> 可挖矿 2 -> 已挖成功 3-> 已关闭
int32 status = 2;
// genesis 创建的私钥比较特殊
bool isGenesis = 3;
//创建时间
int64 createTime = 4;
//挖矿时间
int64 minerTime = 5;
//挖到的币的数目
int64 minerValue = 8;
string minerAddress = 6;
// return wallet
string returnAddress = 7;
}
\ No newline at end of file
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package types
package ticket
var (
// TicketPrefix ticket prefix
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: ticket.proto
package ticket
import (
fmt "fmt"
math "math"
proto "github.com/golang/protobuf/proto"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type Ticket struct {
TicketId string `protobuf:"bytes,1,opt,name=ticketId,proto3" json:"ticketId,omitempty"`
// 0 -> 未成熟 1 -> 可挖矿 2 -> 已挖成功 3-> 已关闭
Status int32 `protobuf:"varint,2,opt,name=status,proto3" json:"status,omitempty"`
// genesis 创建的私钥比较特殊
IsGenesis bool `protobuf:"varint,3,opt,name=isGenesis,proto3" json:"isGenesis,omitempty"`
//创建时间
CreateTime int64 `protobuf:"varint,4,opt,name=createTime,proto3" json:"createTime,omitempty"`
//挖矿时间
MinerTime int64 `protobuf:"varint,5,opt,name=minerTime,proto3" json:"minerTime,omitempty"`
//挖到的币的数目
MinerValue int64 `protobuf:"varint,8,opt,name=minerValue,proto3" json:"minerValue,omitempty"`
MinerAddress string `protobuf:"bytes,6,opt,name=minerAddress,proto3" json:"minerAddress,omitempty"`
// return wallet
ReturnAddress string `protobuf:"bytes,7,opt,name=returnAddress,proto3" json:"returnAddress,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Ticket) Reset() { *m = Ticket{} }
func (m *Ticket) String() string { return proto.CompactTextString(m) }
func (*Ticket) ProtoMessage() {}
func (*Ticket) Descriptor() ([]byte, []int) {
return fileDescriptor_98a6c21780e82d22, []int{0}
}
func (m *Ticket) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Ticket.Unmarshal(m, b)
}
func (m *Ticket) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Ticket.Marshal(b, m, deterministic)
}
func (m *Ticket) XXX_Merge(src proto.Message) {
xxx_messageInfo_Ticket.Merge(m, src)
}
func (m *Ticket) XXX_Size() int {
return xxx_messageInfo_Ticket.Size(m)
}
func (m *Ticket) XXX_DiscardUnknown() {
xxx_messageInfo_Ticket.DiscardUnknown(m)
}
var xxx_messageInfo_Ticket proto.InternalMessageInfo
func (m *Ticket) GetTicketId() string {
if m != nil {
return m.TicketId
}
return ""
}
func (m *Ticket) GetStatus() int32 {
if m != nil {
return m.Status
}
return 0
}
func (m *Ticket) GetIsGenesis() bool {
if m != nil {
return m.IsGenesis
}
return false
}
func (m *Ticket) GetCreateTime() int64 {
if m != nil {
return m.CreateTime
}
return 0
}
func (m *Ticket) GetMinerTime() int64 {
if m != nil {
return m.MinerTime
}
return 0
}
func (m *Ticket) GetMinerValue() int64 {
if m != nil {
return m.MinerValue
}
return 0
}
func (m *Ticket) GetMinerAddress() string {
if m != nil {
return m.MinerAddress
}
return ""
}
func (m *Ticket) GetReturnAddress() string {
if m != nil {
return m.ReturnAddress
}
return ""
}
func init() {
proto.RegisterType((*Ticket)(nil), "ticket.Ticket")
}
func init() { proto.RegisterFile("ticket.proto", fileDescriptor_98a6c21780e82d22) }
var fileDescriptor_98a6c21780e82d22 = []byte{
// 196 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x90, 0xb1, 0xae, 0x82, 0x30,
0x14, 0x86, 0x53, 0xb8, 0xf4, 0xc2, 0x09, 0x77, 0xe9, 0x70, 0xd3, 0x18, 0x63, 0x1a, 0xe2, 0xd0,
0xc9, 0xc5, 0x27, 0x70, 0x32, 0xae, 0x0d, 0x71, 0x47, 0x38, 0x43, 0xa3, 0x80, 0x69, 0xcb, 0x0b,
0xf8, 0xe4, 0x86, 0x83, 0x8a, 0x6c, 0xfd, 0xbe, 0xff, 0xff, 0x93, 0xe6, 0x40, 0x1e, 0x6c, 0x7d,
0xc5, 0xb0, 0xbb, 0xbb, 0x3e, 0xf4, 0x82, 0x4f, 0x54, 0x3c, 0x22, 0xe0, 0x25, 0x3d, 0xc5, 0x0a,
0xd2, 0x49, 0x9e, 0x1a, 0xc9, 0x14, 0xd3, 0x99, 0xf9, 0xb0, 0xf8, 0x07, 0xee, 0x43, 0x15, 0x06,
0x2f, 0x23, 0xc5, 0x74, 0x62, 0x5e, 0x24, 0xd6, 0x90, 0x59, 0x7f, 0xc4, 0x0e, 0xbd, 0xf5, 0x32,
0x56, 0x4c, 0xa7, 0x66, 0x16, 0x62, 0x03, 0x50, 0x3b, 0xac, 0x02, 0x96, 0xb6, 0x45, 0xf9, 0xa3,
0x98, 0x8e, 0xcd, 0x97, 0x19, 0xd7, 0xad, 0xed, 0xd0, 0x51, 0x9c, 0x50, 0x3c, 0x8b, 0x71, 0x4d,
0x70, 0xae, 0x6e, 0x03, 0xca, 0x74, 0x5a, 0xcf, 0x46, 0x14, 0x90, 0x13, 0x1d, 0x9a, 0xc6, 0xa1,
0xf7, 0x92, 0xd3, 0x9f, 0x17, 0x4e, 0x6c, 0xe1, 0xcf, 0x61, 0x18, 0x5c, 0xf7, 0x2e, 0xfd, 0x52,
0x69, 0x29, 0x2f, 0x9c, 0x6e, 0xb2, 0x7f, 0x06, 0x00, 0x00, 0xff, 0xff, 0x90, 0x22, 0xb8, 0x7d,
0x23, 0x01, 0x00, 0x00,
}
......@@ -14,7 +14,7 @@ import (
"github.com/33cn/chain33/common"
dbm "github.com/33cn/chain33/common/db"
log "github.com/33cn/chain33/common/log/log15"
ty "github.com/33cn/chain33/system/store/mavl/db/types"
"github.com/33cn/chain33/system/store/mavl/db/ticket"
"github.com/33cn/chain33/types"
farm "github.com/dgryski/go-farm"
"github.com/golang/protobuf/proto"
......@@ -570,10 +570,10 @@ func updateGlobalMemTree(node *Node) {
Size: node.size,
}
if node.height == 0 {
if bytes.HasPrefix(node.key, ty.TicketPrefix) {
ticket := &ty.Ticket{}
err := proto.Unmarshal(node.value, ticket)
if err == nil && ticket.Status == ty.StatusCloseTicket { //ticket为close状态下不做存储
if bytes.HasPrefix(node.key, ticket.TicketPrefix) {
tk := &ticket.Ticket{}
err := proto.Unmarshal(node.value, tk)
if err == nil && tk.Status == ticket.StatusCloseTicket { //ticket为close状态下不做存储
return
}
}
......@@ -602,10 +602,10 @@ func updateLocalMemTree(t *Tree, node *Node) {
Size: node.size,
}
if node.height == 0 {
if bytes.HasPrefix(node.key, ty.TicketPrefix) {
ticket := &ty.Ticket{}
err := proto.Unmarshal(node.value, ticket)
if err == nil && ticket.Status == ty.StatusCloseTicket { //ticket为close状态下不做存储
if bytes.HasPrefix(node.key, ticket.TicketPrefix) {
tk := &ticket.Ticket{}
err := proto.Unmarshal(node.value, tk)
if err == nil && tk.Status == ticket.StatusCloseTicket { //ticket为close状态下不做存储
return
}
}
......
......@@ -111,6 +111,8 @@ type Store struct {
DbCache int32 `protobuf:"varint,4,opt,name=dbCache" json:"dbCache,omitempty"`
// 数据库版本
LocalDBVersion string `protobuf:"bytes,5,opt,name=localdbVersion" json:"localdbVersion,omitempty"`
// 数据库版本
StoreDBVersion string `protobuf:"bytes,5,opt,name=storedbVersion" json:"storedbVersion,omitempty"`
}
// BlockChain 配置
......
......@@ -237,7 +237,7 @@ message UserWrite {
}
message UpgradeMeta {
bool indexing = 1;
bool starting = 1;
string version = 2;
int64 height = 3;
}
\ No newline at end of file
......@@ -1954,7 +1954,7 @@ func (m *UserWrite) GetContent() string {
}
type UpgradeMeta struct {
Indexing bool `protobuf:"varint,1,opt,name=indexing,proto3" json:"indexing,omitempty"`
Starting bool `protobuf:"varint,1,opt,name=starting,proto3" json:"starting,omitempty"`
Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"`
Height int64 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
......@@ -1987,9 +1987,9 @@ func (m *UpgradeMeta) XXX_DiscardUnknown() {
var xxx_messageInfo_UpgradeMeta proto.InternalMessageInfo
func (m *UpgradeMeta) GetIndexing() bool {
func (m *UpgradeMeta) GetStarting() bool {
if m != nil {
return m.Indexing
return m.Starting
}
return false
}
......@@ -2049,7 +2049,7 @@ func init() {
func init() { proto.RegisterFile("transaction.proto", fileDescriptor_2cc4e03d2c28c490) }
var fileDescriptor_2cc4e03d2c28c490 = []byte{
// 1319 bytes of a gzipped FileDescriptorProto
// 1320 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x57, 0xcf, 0x6e, 0x1b, 0xb7,
0x13, 0x86, 0xb4, 0x5a, 0x59, 0x1a, 0x29, 0xf9, 0xc5, 0x8b, 0x20, 0x11, 0x82, 0x5f, 0x13, 0x97,
0x48, 0x81, 0x20, 0x08, 0x64, 0xc0, 0xce, 0xad, 0x05, 0xda, 0x24, 0x6e, 0x93, 0xc0, 0x49, 0x9a,
......@@ -2128,9 +2128,9 @@ var fileDescriptor_2cc4e03d2c28c490 = []byte{
0xa9, 0x1c, 0xd3, 0x4b, 0x2c, 0x78, 0x7b, 0x6c, 0x7c, 0xed, 0xb0, 0x2f, 0xa1, 0xfb, 0xba, 0x40,
0x45, 0x4f, 0x37, 0x32, 0x91, 0x8b, 0x2c, 0xad, 0x4c, 0x0c, 0x30, 0x5f, 0x97, 0x54, 0xe6, 0x1a,
0xdd, 0x5c, 0xe8, 0x72, 0x0f, 0xd9, 0x4f, 0xd0, 0x7b, 0xbd, 0x98, 0x28, 0x31, 0xc6, 0xe7, 0xa8,
0x85, 0x29, 0x21, 0x75, 0x20, 0xcb, 0x27, 0xe4, 0xa1, 0xc3, 0x2b, 0x6c, 0x9c, 0x9c, 0xa2, 0x2a,
0xfc, 0x30, 0xef, 0x72, 0x0f, 0x2f, 0x1a, 0xe5, 0x0f, 0x6f, 0xfd, 0xf8, 0xd9, 0x24, 0xd3, 0xd3,
0xe5, 0xd1, 0x30, 0x95, 0xf3, 0xdd, 0xfd, 0xfd, 0x34, 0xdf, 0x4d, 0xa7, 0x22, 0xcb, 0xf7, 0xf7,
0x77, 0xa9, 0x48, 0x47, 0x6d, 0xfa, 0x17, 0xb6, 0xff, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x72,
0xdc, 0x53, 0x0e, 0xaf, 0x0d, 0x00, 0x00,
0x85, 0x29, 0x61, 0xa1, 0x85, 0xd2, 0x59, 0x3e, 0x21, 0x0f, 0x1d, 0x5e, 0x61, 0xe3, 0xe4, 0x14,
0x55, 0xe1, 0x87, 0x79, 0x97, 0x7b, 0x78, 0xd1, 0x28, 0x7f, 0x78, 0xeb, 0xc7, 0xcf, 0x26, 0x99,
0x9e, 0x2e, 0x8f, 0x86, 0xa9, 0x9c, 0xef, 0xee, 0xef, 0xa7, 0xf9, 0x6e, 0x3a, 0x15, 0x59, 0xbe,
0xbf, 0xbf, 0x4b, 0x45, 0x3a, 0x6a, 0xd3, 0xbf, 0xb0, 0xfd, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff,
0xba, 0x68, 0x0f, 0x9b, 0xaf, 0x0d, 0x00, 0x00,
}
......@@ -134,6 +134,7 @@ func RunChain33(name string) {
//开始区块链模块加载
//channel, rabitmq 等
version.SetLocalDBVersion(cfg.Store.LocalDBVersion)
version.SetStoreDBVersion(cfg.Store.StoreDBVersion)
version.SetAppVersion(cfg.Version)
log.Info(cfg.Title + "-app:" + version.GetAppVersion() + " chain33:" + version.GetVersion() + " localdb:" + version.GetLocalDBVersion())
log.Info("loading queue")
......@@ -155,12 +156,13 @@ func RunChain33(name string) {
log.Info("loading blockchain module")
chain := blockchain.New(cfg.BlockChain)
chain.SetQueueClient(q.Client())
chain.UpgradeChain()
log.Info("loading store module")
s := store.New(cfg.Store, sub.Store)
s.SetQueueClient(q.Client())
chain.Upgrade()
log.Info("loading consensus module")
cs := consensus.New(cfg.Consensus, sub.Consensus)
cs.SetQueueClient(q.Client())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment