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
2e301762
Commit
2e301762
authored
Nov 26, 2018
by
Hugo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix valnode golint problem and set node.peerSet.Size to 0 make test pass
parent
aa1bced9
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
23 additions
and
2 deletions
+23
-2
node.go
plugin/consensus/tendermint/node.go
+1
-1
exec.go
plugin/dapp/valnode/executor/exec.go
+2
-0
exec_del_local.go
plugin/dapp/valnode/executor/exec_del_local.go
+2
-0
exec_local.go
plugin/dapp/valnode/executor/exec_local.go
+2
-0
query.go
plugin/dapp/valnode/executor/query.go
+2
-0
valnode.go
plugin/dapp/valnode/executor/valnode.go
+8
-0
valnode.go
plugin/dapp/valnode/types/valnode.go
+6
-1
No files found.
plugin/consensus/tendermint/node.go
View file @
2e301762
...
@@ -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
}
}
...
...
plugin/dapp/valnode/executor/exec.go
View file @
2e301762
...
@@ -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
...
...
plugin/dapp/valnode/executor/exec_del_local.go
View file @
2e301762
...
@@ -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
{
...
...
plugin/dapp/valnode/executor/exec_local.go
View file @
2e301762
...
@@ -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
{
...
...
plugin/dapp/valnode/executor/query.go
View file @
2e301762
...
@@ -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
()
...
...
plugin/dapp/valnode/executor/valnode.go
View file @
2e301762
...
@@ -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
))
}
}
plugin/dapp/valnode/types/valnode.go
View file @
2e301762
...
@@ -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
{}
}
}
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