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