Commit ebc21f9e authored by liuyuhang's avatar liuyuhang

modify kvmvccmavl update mod

parent 1a1f36c2
......@@ -135,6 +135,8 @@ name="kvmvccmavl"
driver="leveldb"
dbPath="datadir/mavltree"
dbCache=128
# store数据库版本
storedbVersion="1.0.0"
[store.sub.mavl]
enableMavlPrefix=false
......@@ -155,8 +157,6 @@ pruneHeight=10000
enableMemTree=true
# 是否使能mavl叶子节点数据载入内存
enableMemVal=true
# 是否使能升级kvmvcc(在mavl数据上)
enableUpdateKvmvcc=false
[wallet]
minFee=100000
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: js.proto
/*
Package jsproto is a generated protocol buffer package.
It is generated from these files:
js.proto
It has these top-level messages:
Create
Call
JsAction
JsLog
QueryResult
*/
package jsproto
import (
fmt "fmt"
math "math"
proto "github.com/golang/protobuf/proto"
)
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
......@@ -23,37 +33,14 @@ const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
// create action
type Create struct {
Code string `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
Code string `protobuf:"bytes,1,opt,name=code" json:"code,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"`
}
func (m *Create) Reset() { *m = Create{} }
func (m *Create) String() string { return proto.CompactTextString(m) }
func (*Create) ProtoMessage() {}
func (*Create) Descriptor() ([]byte, []int) {
return fileDescriptor_d11539bc790542aa, []int{0}
}
func (m *Create) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Create.Unmarshal(m, b)
}
func (m *Create) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Create.Marshal(b, m, deterministic)
}
func (m *Create) XXX_Merge(src proto.Message) {
xxx_messageInfo_Create.Merge(m, src)
}
func (m *Create) XXX_Size() int {
return xxx_messageInfo_Create.Size(m)
}
func (m *Create) XXX_DiscardUnknown() {
xxx_messageInfo_Create.DiscardUnknown(m)
}
var xxx_messageInfo_Create proto.InternalMessageInfo
func (*Create) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *Create) GetCode() string {
if m != nil {
......@@ -71,38 +58,15 @@ func (m *Create) GetName() string {
// call action
type Call struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Funcname string `protobuf:"bytes,2,opt,name=funcname,proto3" json:"funcname,omitempty"`
Args string `protobuf:"bytes,3,opt,name=args,proto3" json:"args,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
Funcname string `protobuf:"bytes,2,opt,name=funcname" json:"funcname,omitempty"`
Args string `protobuf:"bytes,3,opt,name=args" json:"args,omitempty"`
}
func (m *Call) Reset() { *m = Call{} }
func (m *Call) String() string { return proto.CompactTextString(m) }
func (*Call) ProtoMessage() {}
func (*Call) Descriptor() ([]byte, []int) {
return fileDescriptor_d11539bc790542aa, []int{1}
}
func (m *Call) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Call.Unmarshal(m, b)
}
func (m *Call) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Call.Marshal(b, m, deterministic)
}
func (m *Call) XXX_Merge(src proto.Message) {
xxx_messageInfo_Call.Merge(m, src)
}
func (m *Call) XXX_Size() int {
return xxx_messageInfo_Call.Size(m)
}
func (m *Call) XXX_DiscardUnknown() {
xxx_messageInfo_Call.DiscardUnknown(m)
}
var xxx_messageInfo_Call proto.InternalMessageInfo
func (*Call) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
func (m *Call) GetName() string {
if m != nil {
......@@ -130,51 +94,26 @@ type JsAction struct {
// *JsAction_Create
// *JsAction_Call
Value isJsAction_Value `protobuf_oneof:"value"`
Ty int32 `protobuf:"varint,3,opt,name=ty,proto3" json:"ty,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
Ty int32 `protobuf:"varint,3,opt,name=ty" json:"ty,omitempty"`
}
func (m *JsAction) Reset() { *m = JsAction{} }
func (m *JsAction) String() string { return proto.CompactTextString(m) }
func (*JsAction) ProtoMessage() {}
func (*JsAction) Descriptor() ([]byte, []int) {
return fileDescriptor_d11539bc790542aa, []int{2}
}
func (m *JsAction) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_JsAction.Unmarshal(m, b)
}
func (m *JsAction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_JsAction.Marshal(b, m, deterministic)
}
func (m *JsAction) XXX_Merge(src proto.Message) {
xxx_messageInfo_JsAction.Merge(m, src)
}
func (m *JsAction) XXX_Size() int {
return xxx_messageInfo_JsAction.Size(m)
}
func (m *JsAction) XXX_DiscardUnknown() {
xxx_messageInfo_JsAction.DiscardUnknown(m)
}
var xxx_messageInfo_JsAction proto.InternalMessageInfo
func (*JsAction) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
type isJsAction_Value interface {
isJsAction_Value()
}
type JsAction_Create struct {
Create *Create `protobuf:"bytes,1,opt,name=create,proto3,oneof"`
Create *Create `protobuf:"bytes,1,opt,name=create,oneof"`
}
type JsAction_Call struct {
Call *Call `protobuf:"bytes,2,opt,name=call,proto3,oneof"`
Call *Call `protobuf:"bytes,2,opt,name=call,oneof"`
}
func (*JsAction_Create) isJsAction_Value() {}
func (*JsAction_Call) isJsAction_Value() {}
func (m *JsAction) GetValue() isJsAction_Value {
......@@ -264,12 +203,12 @@ func _JsAction_OneofSizer(msg proto.Message) (n int) {
switch x := m.Value.(type) {
case *JsAction_Create:
s := proto.Size(x.Create)
n += 1 // tag and wire
n += proto.SizeVarint(1<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *JsAction_Call:
s := proto.Size(x.Call)
n += 1 // tag and wire
n += proto.SizeVarint(2<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case nil:
......@@ -280,36 +219,13 @@ func _JsAction_OneofSizer(msg proto.Message) (n int) {
}
type JsLog struct {
Data string `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
Data string `protobuf:"bytes,1,opt,name=data" json:"data,omitempty"`
}
func (m *JsLog) Reset() { *m = JsLog{} }
func (m *JsLog) String() string { return proto.CompactTextString(m) }
func (*JsLog) ProtoMessage() {}
func (*JsLog) Descriptor() ([]byte, []int) {
return fileDescriptor_d11539bc790542aa, []int{3}
}
func (m *JsLog) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_JsLog.Unmarshal(m, b)
}
func (m *JsLog) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_JsLog.Marshal(b, m, deterministic)
}
func (m *JsLog) XXX_Merge(src proto.Message) {
xxx_messageInfo_JsLog.Merge(m, src)
}
func (m *JsLog) XXX_Size() int {
return xxx_messageInfo_JsLog.Size(m)
}
func (m *JsLog) XXX_DiscardUnknown() {
xxx_messageInfo_JsLog.DiscardUnknown(m)
}
var xxx_messageInfo_JsLog proto.InternalMessageInfo
func (*JsLog) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
func (m *JsLog) GetData() string {
if m != nil {
......@@ -319,36 +235,13 @@ func (m *JsLog) GetData() string {
}
type QueryResult struct {
Data string `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
Data string `protobuf:"bytes,1,opt,name=data" json:"data,omitempty"`
}
func (m *QueryResult) Reset() { *m = QueryResult{} }
func (m *QueryResult) String() string { return proto.CompactTextString(m) }
func (*QueryResult) ProtoMessage() {}
func (*QueryResult) Descriptor() ([]byte, []int) {
return fileDescriptor_d11539bc790542aa, []int{4}
}
func (m *QueryResult) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_QueryResult.Unmarshal(m, b)
}
func (m *QueryResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_QueryResult.Marshal(b, m, deterministic)
}
func (m *QueryResult) XXX_Merge(src proto.Message) {
xxx_messageInfo_QueryResult.Merge(m, src)
}
func (m *QueryResult) XXX_Size() int {
return xxx_messageInfo_QueryResult.Size(m)
}
func (m *QueryResult) XXX_DiscardUnknown() {
xxx_messageInfo_QueryResult.DiscardUnknown(m)
}
var xxx_messageInfo_QueryResult proto.InternalMessageInfo
func (*QueryResult) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} }
func (m *QueryResult) GetData() string {
if m != nil {
......@@ -365,9 +258,9 @@ func init() {
proto.RegisterType((*QueryResult)(nil), "jsproto.QueryResult")
}
func init() { proto.RegisterFile("js.proto", fileDescriptor_d11539bc790542aa) }
func init() { proto.RegisterFile("js.proto", fileDescriptor0) }
var fileDescriptor_d11539bc790542aa = []byte{
var fileDescriptor0 = []byte{
// 231 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x8f, 0xbf, 0x4e, 0xc3, 0x30,
0x10, 0xc6, 0x9b, 0x90, 0xa4, 0xe1, 0x22, 0x40, 0xf2, 0x14, 0xc1, 0x02, 0x66, 0x81, 0x25, 0x42,
......
This diff is collapsed.
This diff is collapsed.
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: norm.proto
/*
Package types is a generated protocol buffer package.
It is generated from these files:
norm.proto
It has these top-level messages:
Norm
NormAction
NormPut
NormGetKey
*/
package types
import (
fmt "fmt"
math "math"
proto "github.com/golang/protobuf/proto"
)
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
......@@ -23,38 +32,15 @@ const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type Norm struct {
NormId []byte `protobuf:"bytes,1,opt,name=normId,proto3" json:"normId,omitempty"`
CreateTime int64 `protobuf:"varint,2,opt,name=createTime,proto3" json:"createTime,omitempty"`
CreateTime int64 `protobuf:"varint,2,opt,name=createTime" json:"createTime,omitempty"`
Key []byte `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"`
Value []byte `protobuf:"bytes,4,opt,name=value,proto3" json:"value,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Norm) Reset() { *m = Norm{} }
func (m *Norm) String() string { return proto.CompactTextString(m) }
func (*Norm) ProtoMessage() {}
func (*Norm) Descriptor() ([]byte, []int) {
return fileDescriptor_4c505000707f0293, []int{0}
}
func (m *Norm) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Norm.Unmarshal(m, b)
}
func (m *Norm) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Norm.Marshal(b, m, deterministic)
}
func (m *Norm) XXX_Merge(src proto.Message) {
xxx_messageInfo_Norm.Merge(m, src)
}
func (m *Norm) XXX_Size() int {
return xxx_messageInfo_Norm.Size(m)
}
func (m *Norm) XXX_DiscardUnknown() {
xxx_messageInfo_Norm.DiscardUnknown(m)
}
var xxx_messageInfo_Norm proto.InternalMessageInfo
func (*Norm) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *Norm) GetNormId() []byte {
if m != nil {
......@@ -88,43 +74,20 @@ type NormAction struct {
// Types that are valid to be assigned to Value:
// *NormAction_Nput
Value isNormAction_Value `protobuf_oneof:"value"`
Ty int32 `protobuf:"varint,5,opt,name=ty,proto3" json:"ty,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
Ty int32 `protobuf:"varint,5,opt,name=ty" json:"ty,omitempty"`
}
func (m *NormAction) Reset() { *m = NormAction{} }
func (m *NormAction) String() string { return proto.CompactTextString(m) }
func (*NormAction) ProtoMessage() {}
func (*NormAction) Descriptor() ([]byte, []int) {
return fileDescriptor_4c505000707f0293, []int{1}
}
func (m *NormAction) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_NormAction.Unmarshal(m, b)
}
func (m *NormAction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_NormAction.Marshal(b, m, deterministic)
}
func (m *NormAction) XXX_Merge(src proto.Message) {
xxx_messageInfo_NormAction.Merge(m, src)
}
func (m *NormAction) XXX_Size() int {
return xxx_messageInfo_NormAction.Size(m)
}
func (m *NormAction) XXX_DiscardUnknown() {
xxx_messageInfo_NormAction.DiscardUnknown(m)
}
var xxx_messageInfo_NormAction proto.InternalMessageInfo
func (*NormAction) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
type isNormAction_Value interface {
isNormAction_Value()
}
type NormAction_Nput struct {
Nput *NormPut `protobuf:"bytes,1,opt,name=nput,proto3,oneof"`
Nput *NormPut `protobuf:"bytes,1,opt,name=nput,oneof"`
}
func (*NormAction_Nput) isNormAction_Value() {}
......@@ -195,7 +158,7 @@ func _NormAction_OneofSizer(msg proto.Message) (n int) {
switch x := m.Value.(type) {
case *NormAction_Nput:
s := proto.Size(x.Nput)
n += 1 // tag and wire
n += proto.SizeVarint(1<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case nil:
......@@ -208,35 +171,12 @@ func _NormAction_OneofSizer(msg proto.Message) (n int) {
type NormPut struct {
Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *NormPut) Reset() { *m = NormPut{} }
func (m *NormPut) String() string { return proto.CompactTextString(m) }
func (*NormPut) ProtoMessage() {}
func (*NormPut) Descriptor() ([]byte, []int) {
return fileDescriptor_4c505000707f0293, []int{2}
}
func (m *NormPut) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_NormPut.Unmarshal(m, b)
}
func (m *NormPut) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_NormPut.Marshal(b, m, deterministic)
}
func (m *NormPut) XXX_Merge(src proto.Message) {
xxx_messageInfo_NormPut.Merge(m, src)
}
func (m *NormPut) XXX_Size() int {
return xxx_messageInfo_NormPut.Size(m)
}
func (m *NormPut) XXX_DiscardUnknown() {
xxx_messageInfo_NormPut.DiscardUnknown(m)
}
var xxx_messageInfo_NormPut proto.InternalMessageInfo
func (*NormPut) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
func (m *NormPut) GetKey() []byte {
if m != nil {
......@@ -254,35 +194,12 @@ func (m *NormPut) GetValue() []byte {
type NormGetKey struct {
Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *NormGetKey) Reset() { *m = NormGetKey{} }
func (m *NormGetKey) String() string { return proto.CompactTextString(m) }
func (*NormGetKey) ProtoMessage() {}
func (*NormGetKey) Descriptor() ([]byte, []int) {
return fileDescriptor_4c505000707f0293, []int{3}
}
func (m *NormGetKey) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_NormGetKey.Unmarshal(m, b)
}
func (m *NormGetKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_NormGetKey.Marshal(b, m, deterministic)
}
func (m *NormGetKey) XXX_Merge(src proto.Message) {
xxx_messageInfo_NormGetKey.Merge(m, src)
}
func (m *NormGetKey) XXX_Size() int {
return xxx_messageInfo_NormGetKey.Size(m)
}
func (m *NormGetKey) XXX_DiscardUnknown() {
xxx_messageInfo_NormGetKey.DiscardUnknown(m)
}
var xxx_messageInfo_NormGetKey proto.InternalMessageInfo
func (*NormGetKey) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
func (m *NormGetKey) GetKey() []byte {
if m != nil {
......@@ -298,9 +215,9 @@ func init() {
proto.RegisterType((*NormGetKey)(nil), "types.NormGetKey")
}
func init() { proto.RegisterFile("norm.proto", fileDescriptor_4c505000707f0293) }
func init() { proto.RegisterFile("norm.proto", fileDescriptor0) }
var fileDescriptor_4c505000707f0293 = []byte{
var fileDescriptor0 = []byte{
// 209 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0xca, 0xcb, 0x2f, 0xca,
0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x2d, 0xa9, 0x2c, 0x48, 0x2d, 0x56, 0x4a, 0xe3,
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -33,11 +33,6 @@ var (
delMavlDataState int32
wg sync.WaitGroup
quit bool
// 用来阻塞查看当前是否需要升级数据库
done chan struct{}
// 使能mavl在当前区块基础上升级kvmvcc
enableUpdateKvmvcc bool
)
const (
......@@ -59,7 +54,6 @@ func DisableLog() {
func init() {
drivers.Reg("kvmvccmavl", New)
done = make(chan struct{}, 1)
}
// KVmMavlStore provide kvmvcc and mavl store interface implementation
......@@ -97,7 +91,6 @@ type subConfig struct {
EnableMemTree bool `json:"enableMemTree"`
// 是否使能内存树中叶子节点
EnableMemVal bool `json:"enableMemVal"`
EnableUpdateKvmvcc bool `json:"enableUpdateKvmvcc"`
}
// New construct KVMVCCStore module
......@@ -120,10 +113,6 @@ func New(cfg *types.Store, sub []byte) queue.Module {
subMavlcfg.EnableMemVal = subcfg.EnableMemVal
}
if subcfg.EnableUpdateKvmvcc {
enableUpdateKvmvcc = true
}
bs := drivers.NewBaseStore(cfg)
cache, err := lru.New(cacheSize)
if err != nil {
......@@ -261,41 +250,10 @@ func (kvmMavls *KVmMavlStore) IterateRangeByStateHash(statehash []byte, start []
// ProcEvent handles supported events
func (kvmMavls *KVmMavlStore) ProcEvent(msg *queue.Message) {
//msg.ReplyErr("KVmMavlStore", types.ErrActionNotSupport)
client := kvmMavls.GetQueueClient()
if msg != nil && msg.Ty == types.EventReExecBlock {
reData := msg.GetData().(*types.ReplyString)
if reData.Data == "over" {
kmlog.Info("ProcEvent update store over")
msg.ReplyErr("KVmMavlStore", nil)
done <- struct{}{}
return
}
} else if msg == nil {
if !enableUpdateKvmvcc {
if msg == nil {
return
}
height, err := kvmMavls.KVMVCCStore.GetMaxVersion()
if err != nil {
height = 0
} else {
height++
}
msg1 := client.NewMessage("blockchain", types.EventReExecBlock, &types.ReqInt{Height: height})
err = client.Send(msg1, true)
if err != nil {
return
}
resp, err := client.Wait(msg1)
if err != nil {
return
}
data := resp.GetData().(*types.ReplyString)
if data.Data == "need" {
//进程阻塞
<-done
}
}
msg.ReplyErr("KVmMavlStore", types.ErrActionNotSupport)
}
// MemSetUpgrade set kvs to the mem of KVmMavlStore module not cache the tree and return the StateHash
......
......@@ -19,11 +19,9 @@ import (
"github.com/33cn/chain33/common"
dbm "github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/queue"
qmocks "github.com/33cn/chain33/queue/mocks"
drivers "github.com/33cn/chain33/system/store"
"github.com/33cn/chain33/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
)
......@@ -539,10 +537,6 @@ func TestIterateRangeByStateHash(t *testing.T) {
assert.Equal(t, int64(0), resp.Amount)
}
type testClient struct {
qmocks.Client
}
func TestProcEvent(t *testing.T) {
dir, err := ioutil.TempDir("", "example")
assert.Nil(t, err)
......@@ -552,19 +546,6 @@ func TestProcEvent(t *testing.T) {
store := New(storeCfg, sub).(*KVmMavlStore)
assert.NotNil(t, store)
client := &qmocks.Client{}
client.On("Send", mock.Anything, mock.Anything).Return(nil)
client.On("Sub", mock.Anything, mock.Anything).Return(nil)
client.On("Recv", mock.Anything, mock.Anything).Return(nil)
client.On("NewMessage", mock.Anything, mock.Anything, mock.Anything).Return(nil).Once()
client.On("Wait", mock.Anything).Return(&queue.Message{Data: &types.ReplyString{Data: "other"}}, nil).Once()
store.SetQueueClient(client)
store.ProcEvent(nil)
enableUpdateKvmvcc = true
defer func() {
enableUpdateKvmvcc = false
}()
store.ProcEvent(nil)
store.ProcEvent(&queue.Message{})
}
......
......@@ -1092,7 +1092,7 @@ func (bs *BlockStore) SetUpgradeMeta(meta *types.UpgradeMeta) error {
return bs.db.SetSync(version.LocalDBMeta, verByte)
}
//SetStoreUpgradeMeta 获取存在blockchain中的Store的数据库版本号
//GetStoreUpgradeMeta 获取存在blockchain中的Store的数据库版本号
func (bs *BlockStore) GetStoreUpgradeMeta() (*types.UpgradeMeta, error) {
ver := types.UpgradeMeta{}
version, err := bs.db.Get(version.StoreDBMeta)
......
......@@ -128,6 +128,7 @@ func TestBlockChain(t *testing.T) {
testWriteBlockToDbTemp(t, blockchain)
testReadBlockToExec(t, blockchain)
testReExecBlock(t, blockchain)
testUpgradeStore(t, blockchain)
}
func testProcAddBlockMsg(t *testing.T, mock33 *testnode.Chain33Mock, blockchain *blockchain.BlockChain) {
......@@ -1117,3 +1118,9 @@ func testReExecBlock(t *testing.T, chain *blockchain.BlockChain) {
chain.ReExecBlock(0, curheight)
chainlog.Info("ReExecBlock end ---------------------")
}
func testUpgradeStore(t *testing.T, chain *blockchain.BlockChain) {
chainlog.Info("UpgradeStore begin ---------------------")
chain.UpgradeStore()
chainlog.Info("UpgradeStore end ---------------------")
}
......@@ -200,9 +200,9 @@ driver="leveldb"
dbPath="datadir/mavltree"
# Cache大小
dbCache=128
# 数据库版本
# local数据库版本
localdbVersion="1.0.0"
# 状态数据库版本
# store数据库版本
storedbVersion="1.0.0"
[store.sub.mavl]
......
......@@ -54,16 +54,16 @@ func SetLocalDBVersion(version string) {
//GetStoreDBVersion 数据库版本解析
/*
格式: v1.v2.v3
如果: v1 升级了, 那么意味着localdb 需要 重新 reindex
如果: v1 升级了, 那么意味着storedb 需要升级
*/
func GetStoreDBVersion() string {
return localversion
return storeversion
}
//SetStoreDBVersion 通过设置版本号,强制重建数据库
func SetStoreDBVersion(version string) {
if version != "" {
localversion = version
storeversion = version
}
}
......
......@@ -160,6 +160,26 @@ func decodeTx(hexstr string) (*types.Transaction, error) {
return &tx, nil
}
// SendRawTransaction send rawtransaction by p2p
func (c *channelClient) SendRawTransaction(param *types.SignedTx) (*types.Reply, error) {
if param == nil {
err := types.ErrInvalidParam
log.Error("SendRawTransaction", "Error", err)
return nil, err
}
var tx types.Transaction
err := types.Decode(param.GetUnsign(), &tx)
if err == nil {
tx.Signature = &types.Signature{
Ty: param.GetTy(),
Pubkey: param.GetPubkey(),
Signature: param.GetSign(),
}
return c.SendTx(&tx)
}
return nil, err
}
// GetAddrOverview get overview of address
func (c *channelClient) GetAddrOverview(parm *types.ReqAddr) (*types.AddrOverview, error) {
err := address.CheckAddress(parm.Addr)
......
......@@ -80,6 +80,11 @@ func (g *Grpc) CreateRawTxGroup(ctx context.Context, in *pb.CreateTransactionGro
return &pb.UnsignTx{Data: reply}, nil
}
// SendRawTransaction send rawtransaction
func (g *Grpc) SendRawTransaction(ctx context.Context, in *pb.SignedTx) (*pb.Reply, error) {
return g.cli.SendRawTransaction(in)
}
// QueryTransaction query transaction by grpc
func (g *Grpc) QueryTransaction(ctx context.Context, in *pb.ReqHash) (*pb.TransactionDetail, error) {
return g.cli.QueryTx(in)
......
......@@ -8,6 +8,7 @@ import (
"context"
"encoding/hex"
"encoding/json"
"fmt"
"time"
"github.com/33cn/chain33/common"
......@@ -82,6 +83,36 @@ func (c *Chain33) CreateNoBalanceTransaction(in *types.NoBalanceTx, result *stri
return nil
}
// SendRawTransaction send rawtransacion
func (c *Chain33) SendRawTransaction(in rpctypes.SignedTx, result *interface{}) error {
var stx types.SignedTx
var err error
stx.Pubkey, err = hex.DecodeString(in.Pubkey)
if err != nil {
return err
}
stx.Sign, err = hex.DecodeString(in.Sign)
if err != nil {
return err
}
stx.Unsign, err = hex.DecodeString(in.Unsign)
if err != nil {
return err
}
stx.Ty = in.Ty
reply, err := c.cli.SendRawTransaction(&stx)
if err != nil {
return err
}
if reply.IsOk {
*result = "0x" + hex.EncodeToString(reply.Msg)
return nil
}
return fmt.Errorf(string(reply.Msg))
}
// SendTransaction send transaction
func (c *Chain33) SendTransaction(in rpctypes.RawParm, result *interface{}) error {
var parm types.Transaction
......
......@@ -14,6 +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/types"
farm "github.com/dgryski/go-farm"
"github.com/golang/protobuf/proto"
......@@ -569,6 +570,13 @@ 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状态下不做存储
return
}
}
memN.data = make([][]byte, 4)
memN.data[3] = node.value
} else {
......@@ -594,6 +602,13 @@ 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状态下不做存储
return
}
}
memN.data = make([][]byte, 4)
memN.data[3] = node.value
} else {
......
......@@ -81,8 +81,6 @@ type Consensus struct {
Genesis string `protobuf:"bytes,4,opt,name=genesis" json:"genesis,omitempty"`
HotkeyAddr string `protobuf:"bytes,5,opt,name=hotkeyAddr" json:"hotkeyAddr,omitempty"`
ForceMining bool `protobuf:"varint,6,opt,name=forceMining" json:"forceMining,omitempty"`
// 配置挖矿的合约名单
MinerExecs []string `protobuf:"bytes,7,rep,name=minerExecs" json:"minerExecs,omitempty"`
}
// Wallet 配置
......
......@@ -20,6 +20,8 @@ service chain33 {
//交易接口
rpc CreateRawTransaction(CreateTx) returns (UnsignTx) {}
rpc CreateRawTxGroup(CreateTransactionGroup) returns (UnsignTx) {}
//发送签名后交易
rpc SendRawTransaction(SignedTx) returns (Reply) {}
// 根据哈希查询交易
rpc QueryTransaction(ReqHash) returns (TransactionDetail) {}
// 发送交易
......
......@@ -76,6 +76,13 @@ message NoBalanceTx {
string expire = 4;
}
message SignedTx {
bytes unsign = 1;
bytes sign = 2;
bytes pubkey = 3;
int32 ty = 4;
}
message Transaction {
bytes execer = 1;
bytes payload = 2;
......
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