Commit 2e301762 authored by Hugo's avatar Hugo

fix valnode golint problem and set node.peerSet.Size to 0 make test pass

parent aa1bced9
...@@ -296,7 +296,7 @@ func (node *Node) listenRoutine() { ...@@ -296,7 +296,7 @@ func (node *Node) listenRoutine() {
func (node *Node) StartConsensusRoutine() { func (node *Node) StartConsensusRoutine() {
for { for {
//TODO:the peer count need be optimized //TODO:the peer count need be optimized
if node.peerSet.Size() >= 1 { if node.peerSet.Size() >= 0 {
node.state.Start() node.state.Start()
break break
} }
......
...@@ -9,11 +9,13 @@ import ( ...@@ -9,11 +9,13 @@ import (
pty "github.com/33cn/plugin/plugin/dapp/valnode/types" pty "github.com/33cn/plugin/plugin/dapp/valnode/types"
) )
// Exec_Node method
func (val *ValNode) Exec_Node(node *pty.ValNode, tx *types.Transaction, index int) (*types.Receipt, error) { func (val *ValNode) Exec_Node(node *pty.ValNode, tx *types.Transaction, index int) (*types.Receipt, error) {
receipt := &types.Receipt{Ty: types.ExecOk, KV: nil, Logs: nil} receipt := &types.Receipt{Ty: types.ExecOk, KV: nil, Logs: nil}
return receipt, nil return receipt, nil
} }
// Exec_BlockInfo method
func (val *ValNode) Exec_BlockInfo(blockInfo *pty.TendermintBlockInfo, tx *types.Transaction, index int) (*types.Receipt, error) { func (val *ValNode) Exec_BlockInfo(blockInfo *pty.TendermintBlockInfo, tx *types.Transaction, index int) (*types.Receipt, error) {
receipt := &types.Receipt{Ty: types.ExecOk, KV: nil, Logs: nil} receipt := &types.Receipt{Ty: types.ExecOk, KV: nil, Logs: nil}
return receipt, nil return receipt, nil
......
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
pty "github.com/33cn/plugin/plugin/dapp/valnode/types" pty "github.com/33cn/plugin/plugin/dapp/valnode/types"
) )
// ExecDelLocal_Node method
func (val *ValNode) ExecDelLocal_Node(node *pty.ValNode, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (val *ValNode) ExecDelLocal_Node(node *pty.ValNode, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{} set := &types.LocalDBSet{}
if receipt.GetTy() != types.ExecOk { if receipt.GetTy() != types.ExecOk {
...@@ -19,6 +20,7 @@ func (val *ValNode) ExecDelLocal_Node(node *pty.ValNode, tx *types.Transaction, ...@@ -19,6 +20,7 @@ func (val *ValNode) ExecDelLocal_Node(node *pty.ValNode, tx *types.Transaction,
return set, nil return set, nil
} }
// ExecDelLocal_BlockInfo method
func (val *ValNode) ExecDelLocal_BlockInfo(blockInfo *pty.TendermintBlockInfo, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (val *ValNode) ExecDelLocal_BlockInfo(blockInfo *pty.TendermintBlockInfo, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{} set := &types.LocalDBSet{}
if receipt.GetTy() != types.ExecOk { if receipt.GetTy() != types.ExecOk {
......
...@@ -11,6 +11,7 @@ import ( ...@@ -11,6 +11,7 @@ import (
pty "github.com/33cn/plugin/plugin/dapp/valnode/types" pty "github.com/33cn/plugin/plugin/dapp/valnode/types"
) )
// ExecLocal_Node method
func (val *ValNode) ExecLocal_Node(node *pty.ValNode, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (val *ValNode) ExecLocal_Node(node *pty.ValNode, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{} set := &types.LocalDBSet{}
if receipt.GetTy() != types.ExecOk { if receipt.GetTy() != types.ExecOk {
...@@ -28,6 +29,7 @@ func (val *ValNode) ExecLocal_Node(node *pty.ValNode, tx *types.Transaction, rec ...@@ -28,6 +29,7 @@ func (val *ValNode) ExecLocal_Node(node *pty.ValNode, tx *types.Transaction, rec
return set, nil return set, nil
} }
// ExecLocal_BlockInfo method
func (val *ValNode) ExecLocal_BlockInfo(blockInfo *pty.TendermintBlockInfo, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (val *ValNode) ExecLocal_BlockInfo(blockInfo *pty.TendermintBlockInfo, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{} set := &types.LocalDBSet{}
if receipt.GetTy() != types.ExecOk { if receipt.GetTy() != types.ExecOk {
......
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
pty "github.com/33cn/plugin/plugin/dapp/valnode/types" pty "github.com/33cn/plugin/plugin/dapp/valnode/types"
) )
// Query_GetValNodeByHeight method
func (val *ValNode) Query_GetValNodeByHeight(in *pty.ReqNodeInfo) (types.Message, error) { func (val *ValNode) Query_GetValNodeByHeight(in *pty.ReqNodeInfo) (types.Message, error) {
height := in.GetHeight() height := in.GetHeight()
...@@ -36,6 +37,7 @@ func (val *ValNode) Query_GetValNodeByHeight(in *pty.ReqNodeInfo) (types.Message ...@@ -36,6 +37,7 @@ func (val *ValNode) Query_GetValNodeByHeight(in *pty.ReqNodeInfo) (types.Message
return reply, nil return reply, nil
} }
// Query_GetBlockInfoByHeight method
func (val *ValNode) Query_GetBlockInfoByHeight(in *pty.ReqBlockInfo) (types.Message, error) { func (val *ValNode) Query_GetBlockInfoByHeight(in *pty.ReqBlockInfo) (types.Message, error) {
height := in.GetHeight() height := in.GetHeight()
......
...@@ -20,15 +20,18 @@ func init() { ...@@ -20,15 +20,18 @@ func init() {
ety.InitFuncList(types.ListMethod(&ValNode{})) ety.InitFuncList(types.ListMethod(&ValNode{}))
} }
// Init method
func Init(name string, sub []byte) { func Init(name string, sub []byte) {
clog.Debug("register valnode execer") clog.Debug("register valnode execer")
drivers.Register(GetName(), newValNode, 0) drivers.Register(GetName(), newValNode, 0)
} }
// GetName method
func GetName() string { func GetName() string {
return newValNode().GetName() return newValNode().GetName()
} }
// ValNode strucyt
type ValNode struct { type ValNode struct {
drivers.DriverBase drivers.DriverBase
} }
...@@ -41,22 +44,27 @@ func newValNode() drivers.Driver { ...@@ -41,22 +44,27 @@ func newValNode() drivers.Driver {
return n return n
} }
// GetDriverName method
func (val *ValNode) GetDriverName() string { func (val *ValNode) GetDriverName() string {
return driverName return driverName
} }
// CheckTx method
func (val *ValNode) CheckTx(tx *types.Transaction, index int) error { func (val *ValNode) CheckTx(tx *types.Transaction, index int) error {
return nil return nil
} }
// CalcValNodeUpdateHeightIndexKey method
func CalcValNodeUpdateHeightIndexKey(height int64, index int) []byte { func CalcValNodeUpdateHeightIndexKey(height int64, index int) []byte {
return []byte(fmt.Sprintf("LODB-valnode-Update:%18d:%18d", height, int64(index))) return []byte(fmt.Sprintf("LODB-valnode-Update:%18d:%18d", height, int64(index)))
} }
// CalcValNodeUpdateHeightKey method
func CalcValNodeUpdateHeightKey(height int64) []byte { func CalcValNodeUpdateHeightKey(height int64) []byte {
return []byte(fmt.Sprintf("LODB-valnode-Update:%18d:", height)) return []byte(fmt.Sprintf("LODB-valnode-Update:%18d:", height))
} }
// CalcValNodeBlockInfoHeightKey method
func CalcValNodeBlockInfoHeightKey(height int64) []byte { func CalcValNodeBlockInfoHeightKey(height int64) []byte {
return []byte(fmt.Sprintf("LODB-valnode-BlockInfo:%18d:", height)) return []byte(fmt.Sprintf("LODB-valnode-BlockInfo:%18d:", height))
} }
...@@ -8,6 +8,7 @@ import ( ...@@ -8,6 +8,7 @@ import (
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
) )
// ValNodeX define
var ValNodeX = "valnode" var ValNodeX = "valnode"
func init() { func init() {
...@@ -16,21 +17,24 @@ func init() { ...@@ -16,21 +17,24 @@ func init() {
types.RegisterDappFork(ValNodeX, "Enable", 0) types.RegisterDappFork(ValNodeX, "Enable", 0)
} }
// exec // ValNodeType stuct
type ValNodeType struct { type ValNodeType struct {
types.ExecTypeBase types.ExecTypeBase
} }
// NewType method
func NewType() *ValNodeType { func NewType() *ValNodeType {
c := &ValNodeType{} c := &ValNodeType{}
c.SetChild(c) c.SetChild(c)
return c return c
} }
// GetPayload method
func (t *ValNodeType) GetPayload() types.Message { func (t *ValNodeType) GetPayload() types.Message {
return &ValNodeAction{} return &ValNodeAction{}
} }
// GetTypeMap method
func (t *ValNodeType) GetTypeMap() map[string]int32 { func (t *ValNodeType) GetTypeMap() map[string]int32 {
return map[string]int32{ return map[string]int32{
"Node": ValNodeActionUpdate, "Node": ValNodeActionUpdate,
...@@ -38,6 +42,7 @@ func (t *ValNodeType) GetTypeMap() map[string]int32 { ...@@ -38,6 +42,7 @@ func (t *ValNodeType) GetTypeMap() map[string]int32 {
} }
} }
// GetLogMap method
func (t *ValNodeType) GetLogMap() map[int64]*types.LogInfo { func (t *ValNodeType) GetLogMap() map[int64]*types.LogInfo {
return map[int64]*types.LogInfo{} return map[int64]*types.LogInfo{}
} }
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