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
3603d6d7
Commit
3603d6d7
authored
Jan 24, 2019
by
kingwang
Committed by
33cn
Jan 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update 01/24
parent
3f71a8a5
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
107 additions
and
30 deletions
+107
-30
api_test.go
vendor/github.com/33cn/chain33/client/api/api_test.go
+0
-1
api.go
vendor/github.com/33cn/chain33/client/mocks/api.go
+23
-0
queueprotocol.go
vendor/github.com/33cn/chain33/client/queueprotocol.go
+20
-0
queueprotocolapi.go
vendor/github.com/33cn/chain33/client/queueprotocolapi.go
+2
-1
executor.go
vendor/github.com/33cn/chain33/executor/executor.go
+1
-0
api_test.go
vendor/github.com/33cn/chain33/rpc/grpcclient/api_test.go
+0
-3
client.go
vendor/github.com/33cn/chain33/rpc/grpcclient/client.go
+7
-2
jrpchandler.go
vendor/github.com/33cn/chain33/rpc/jrpchandler.go
+26
-20
jrpchandler_test.go
vendor/github.com/33cn/chain33/rpc/jrpchandler_test.go
+20
-0
server.go
vendor/github.com/33cn/chain33/rpc/server.go
+8
-0
server_test.go
vendor/github.com/33cn/chain33/rpc/server_test.go
+0
-2
cfg.go
vendor/github.com/33cn/chain33/types/cfg.go
+0
-1
No files found.
vendor/github.com/33cn/chain33/client/api/api_test.go
View file @
3603d6d7
...
...
@@ -47,7 +47,6 @@ func TestAPI(t *testing.T) {
rpcCfg
:=
new
(
types
.
RPC
)
rpcCfg
.
GrpcBindAddr
=
"127.0.0.1:8003"
rpcCfg
.
JrpcBindAddr
=
"127.0.0.1:8004"
rpcCfg
.
MainnetJrpcAddr
=
rpcCfg
.
JrpcBindAddr
rpcCfg
.
Whitelist
=
[]
string
{
"127.0.0.1"
,
"0.0.0.0"
}
rpcCfg
.
JrpcFuncWhitelist
=
[]
string
{
"*"
}
rpcCfg
.
GrpcFuncWhitelist
=
[]
string
{
"*"
}
...
...
vendor/github.com/33cn/chain33/client/mocks/api.go
View file @
3603d6d7
...
...
@@ -269,6 +269,29 @@ func (_m *QueueProtocolAPI) GetBlockOverview(param *types.ReqHash) (*types.Block
return
r0
,
r1
}
// GetBlockSequences provides a mock function with given fields: param
func
(
_m
*
QueueProtocolAPI
)
GetBlockSequences
(
param
*
types
.
ReqBlocks
)
(
*
types
.
BlockSequences
,
error
)
{
ret
:=
_m
.
Called
(
param
)
var
r0
*
types
.
BlockSequences
if
rf
,
ok
:=
ret
.
Get
(
0
)
.
(
func
(
*
types
.
ReqBlocks
)
*
types
.
BlockSequences
);
ok
{
r0
=
rf
(
param
)
}
else
{
if
ret
.
Get
(
0
)
!=
nil
{
r0
=
ret
.
Get
(
0
)
.
(
*
types
.
BlockSequences
)
}
}
var
r1
error
if
rf
,
ok
:=
ret
.
Get
(
1
)
.
(
func
(
*
types
.
ReqBlocks
)
error
);
ok
{
r1
=
rf
(
param
)
}
else
{
r1
=
ret
.
Error
(
1
)
}
return
r0
,
r1
}
// GetBlocks provides a mock function with given fields: param
func
(
_m
*
QueueProtocolAPI
)
GetBlocks
(
param
*
types
.
ReqBlocks
)
(
*
types
.
BlockDetails
,
error
)
{
ret
:=
_m
.
Called
(
param
)
...
...
vendor/github.com/33cn/chain33/client/queueprotocol.go
View file @
3603d6d7
...
...
@@ -968,6 +968,26 @@ func (q *QueueProtocol) GetBlockBySeq(param *types.Int64) (*types.BlockSeq, erro
return
nil
,
types
.
ErrTypeAsset
}
// GetBlockSequences block执行序列号
func
(
q
*
QueueProtocol
)
GetBlockSequences
(
param
*
types
.
ReqBlocks
)
(
*
types
.
BlockSequences
,
error
)
{
if
param
==
nil
{
err
:=
types
.
ErrInvalidParam
log
.
Error
(
"GetBlockSequences"
,
"Error"
,
err
)
return
nil
,
err
}
msg
,
err
:=
q
.
query
(
blockchainKey
,
types
.
EventGetBlockSequences
,
param
)
if
err
!=
nil
{
log
.
Error
(
"GetBlockSequences"
,
"Error"
,
err
.
Error
())
return
nil
,
err
}
if
reply
,
ok
:=
msg
.
GetData
()
.
(
*
types
.
BlockSequences
);
ok
{
return
reply
,
nil
}
err
=
types
.
ErrTypeAsset
log
.
Error
(
"GetBlockSequences"
,
"Error"
,
err
)
return
nil
,
err
}
// QueryChain query chain
func
(
q
*
QueueProtocol
)
QueryChain
(
param
*
types
.
ChainExecutor
)
(
types
.
Message
,
error
)
{
if
param
==
nil
{
...
...
vendor/github.com/33cn/chain33/client/queueprotocolapi.go
View file @
3603d6d7
...
...
@@ -107,7 +107,8 @@ type QueueProtocolAPI interface {
//types.EventGetLastBlockSequence:
GetLastBlockSequence
()
(
*
types
.
Int64
,
error
)
//types.EventGetBlockSequences:
GetBlockSequences
(
param
*
types
.
ReqBlocks
)
(
*
types
.
BlockSequences
,
error
)
//types.EventGetBlockByHashes:
GetBlockByHashes
(
param
*
types
.
ReqHashes
)
(
*
types
.
BlockDetails
,
error
)
//types.EventGetBlockBySeq:
...
...
vendor/github.com/33cn/chain33/executor/executor.go
View file @
3603d6d7
...
...
@@ -151,6 +151,7 @@ func (exec *Executor) procExecQuery(msg queue.Message) {
driver
.
SetStateDB
(
db
)
driver
.
SetAPI
(
exec
.
qclient
)
driver
.
SetExecutorAPI
(
exec
.
qclient
,
exec
.
grpccli
)
driver
.
SetEnv
(
header
.
GetHeight
(),
header
.
GetBlockTime
(),
uint64
(
header
.
GetDifficulty
()))
//查询的情况下下,执行器不做严格校验,allow,尽可能的加载执行器,并且做查询
ret
,
err
:=
driver
.
Query
(
data
.
FuncName
,
data
.
Param
)
...
...
vendor/github.com/33cn/chain33/rpc/grpcclient/api_test.go
View file @
3603d6d7
...
...
@@ -22,7 +22,6 @@ func TestMultipleGRPC(t *testing.T) {
rpcCfg
:=
new
(
types
.
RPC
)
rpcCfg
.
GrpcBindAddr
=
"127.0.0.1:8003"
rpcCfg
.
JrpcBindAddr
=
"127.0.0.1:8004"
rpcCfg
.
MainnetJrpcAddr
=
rpcCfg
.
JrpcBindAddr
rpcCfg
.
Whitelist
=
[]
string
{
"127.0.0.1"
,
"0.0.0.0"
}
rpcCfg
.
JrpcFuncWhitelist
=
[]
string
{
"*"
}
rpcCfg
.
GrpcFuncWhitelist
=
[]
string
{
"*"
}
...
...
@@ -53,7 +52,6 @@ func TestMultipleGRPCLocalhost(t *testing.T) {
rpcCfg
:=
new
(
types
.
RPC
)
rpcCfg
.
GrpcBindAddr
=
"localhost:8003"
rpcCfg
.
JrpcBindAddr
=
"localhost:8004"
rpcCfg
.
MainnetJrpcAddr
=
rpcCfg
.
JrpcBindAddr
rpcCfg
.
Whitelist
=
[]
string
{
"localhost"
,
"0.0.0.0"
}
rpcCfg
.
JrpcFuncWhitelist
=
[]
string
{
"*"
}
rpcCfg
.
GrpcFuncWhitelist
=
[]
string
{
"*"
}
...
...
@@ -84,7 +82,6 @@ func TestNewParaClient(t *testing.T) {
rpcCfg
:=
new
(
types
.
RPC
)
rpcCfg
.
GrpcBindAddr
=
"127.0.0.1:8003"
rpcCfg
.
JrpcBindAddr
=
"127.0.0.1:8004"
rpcCfg
.
MainnetJrpcAddr
=
rpcCfg
.
JrpcBindAddr
rpcCfg
.
Whitelist
=
[]
string
{
"127.0.0.1"
,
"0.0.0.0"
}
rpcCfg
.
JrpcFuncWhitelist
=
[]
string
{
"*"
}
rpcCfg
.
GrpcFuncWhitelist
=
[]
string
{
"*"
}
...
...
vendor/github.com/33cn/chain33/rpc/grpcclient/client.go
View file @
3603d6d7
...
...
@@ -5,6 +5,9 @@ import (
"google.golang.org/grpc"
)
// paraChainGrpcRecSize 平行链receive最大100M
const
paraChainGrpcRecSize
=
100
*
1024
*
1024
//NewMainChainClient 创建一个平行链的 主链 grpc chain33 客户端
func
NewMainChainClient
(
grpcaddr
string
)
(
types
.
Chain33Client
,
error
)
{
paraRemoteGrpcClient
:=
types
.
Conf
(
"config.consensus.sub.para"
)
.
GStr
(
"ParaRemoteGrpcClient"
)
...
...
@@ -12,9 +15,11 @@ func NewMainChainClient(grpcaddr string) (types.Chain33Client, error) {
paraRemoteGrpcClient
=
grpcaddr
}
if
paraRemoteGrpcClient
==
""
{
paraRemoteGrpcClient
=
"127.0.0.1:8
0
02"
paraRemoteGrpcClient
=
"127.0.0.1:8
8
02"
}
conn
,
err
:=
grpc
.
Dial
(
NewMultipleURL
(
paraRemoteGrpcClient
),
grpc
.
WithInsecure
())
conn
,
err
:=
grpc
.
Dial
(
NewMultipleURL
(
paraRemoteGrpcClient
),
grpc
.
WithInsecure
(),
grpc
.
WithDefaultCallOptions
(
grpc
.
MaxCallRecvMsgSize
(
paraChainGrpcRecSize
)))
if
err
!=
nil
{
return
nil
,
err
}
...
...
vendor/github.com/33cn/chain33/rpc/jrpchandler.go
View file @
3603d6d7
...
...
@@ -5,6 +5,7 @@
package
rpc
import
(
"context"
"encoding/hex"
"encoding/json"
"fmt"
...
...
@@ -12,7 +13,6 @@ import (
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/rpc/jsonclient"
"github.com/33cn/chain33/types"
wcom
"github.com/33cn/chain33/wallet/common"
...
...
@@ -114,26 +114,8 @@ func (c *Chain33) SendRawTransaction(in rpctypes.SignedTx, result *interface{})
return
fmt
.
Errorf
(
string
(
reply
.
Msg
))
}
// used only in parachain
func
forwardTranToMainNet
(
in
rpctypes
.
RawParm
,
result
*
interface
{})
error
{
if
rpcCfg
.
MainnetJrpcAddr
==
""
{
return
types
.
ErrInvalidMainnetRPCAddr
}
rpc
,
err
:=
jsonclient
.
NewJSONClient
(
rpcCfg
.
MainnetJrpcAddr
)
if
err
!=
nil
{
return
err
}
err
=
rpc
.
Call
(
"Chain33.SendTransaction"
,
in
,
result
)
return
err
}
// SendTransaction send transaction
func
(
c
*
Chain33
)
SendTransaction
(
in
rpctypes
.
RawParm
,
result
*
interface
{})
error
{
if
types
.
IsPara
()
{
return
forwardTranToMainNet
(
in
,
result
)
}
var
parm
types
.
Transaction
data
,
err
:=
common
.
FromHex
(
in
.
Data
)
if
err
!=
nil
{
...
...
@@ -141,7 +123,15 @@ func (c *Chain33) SendTransaction(in rpctypes.RawParm, result *interface{}) erro
}
types
.
Decode
(
data
,
&
parm
)
log
.
Debug
(
"SendTransaction"
,
"parm"
,
parm
)
reply
,
err
:=
c
.
cli
.
SendTx
(
&
parm
)
var
reply
*
types
.
Reply
//para chain, forward to main chain
if
types
.
IsPara
()
{
reply
,
err
=
c
.
mainGrpcCli
.
SendTransaction
(
context
.
Background
(),
&
parm
)
}
else
{
reply
,
err
=
c
.
cli
.
SendTx
(
&
parm
)
}
if
err
==
nil
{
*
result
=
common
.
ToHex
(
reply
.
GetMsg
())
}
...
...
@@ -1048,6 +1038,22 @@ func (c *Chain33) GetLastBlockSequence(in *types.ReqNil, result *interface{}) er
return
nil
}
// GetBlockSequences get the block loading sequence number information for the specified interval
func
(
c
*
Chain33
)
GetBlockSequences
(
in
rpctypes
.
BlockParam
,
result
*
interface
{})
error
{
resp
,
err
:=
c
.
cli
.
GetBlockSequences
(
&
types
.
ReqBlocks
{
Start
:
in
.
Start
,
End
:
in
.
End
,
IsDetail
:
in
.
Isdetail
,
Pid
:
[]
string
{
""
}})
if
err
!=
nil
{
return
err
}
var
BlkSeqs
rpctypes
.
ReplyBlkSeqs
items
:=
resp
.
GetItems
()
for
_
,
item
:=
range
items
{
BlkSeqs
.
BlkSeqInfos
=
append
(
BlkSeqs
.
BlkSeqInfos
,
&
rpctypes
.
ReplyBlkSeq
{
Hash
:
common
.
ToHex
(
item
.
GetHash
()),
Type
:
item
.
GetType
()})
}
*
result
=
&
BlkSeqs
return
nil
}
// GetBlockByHashes get block information by hashes
func
(
c
*
Chain33
)
GetBlockByHashes
(
in
rpctypes
.
ReqHashes
,
result
*
interface
{})
error
{
log
.
Warn
(
"GetBlockByHashes"
,
"hashes"
,
in
)
...
...
vendor/github.com/33cn/chain33/rpc/jrpchandler_test.go
View file @
3603d6d7
...
...
@@ -1214,6 +1214,26 @@ func TestChain33_GetLastBlockSequence(t *testing.T) {
assert
.
Equal
(
t
,
int64
(
1
),
result2
)
}
func
TestChain33_GetBlockSequences
(
t
*
testing
.
T
)
{
api
:=
new
(
mocks
.
QueueProtocolAPI
)
client
:=
newTestChain33
(
api
)
var
result
interface
{}
api
.
On
(
"GetBlockSequences"
,
mock
.
Anything
)
.
Return
(
nil
,
types
.
ErrInvalidParam
)
err
:=
client
.
GetBlockSequences
(
rpctypes
.
BlockParam
{},
&
result
)
assert
.
NotNil
(
t
,
err
)
api
=
new
(
mocks
.
QueueProtocolAPI
)
client
=
newTestChain33
(
api
)
var
result2
interface
{}
blocks
:=
types
.
BlockSequences
{}
blocks
.
Items
=
make
([]
*
types
.
BlockSequence
,
0
)
blocks
.
Items
=
append
(
blocks
.
Items
,
&
types
.
BlockSequence
{
Hash
:
[]
byte
(
"h1"
),
Type
:
1
})
api
.
On
(
"GetBlockSequences"
,
mock
.
Anything
)
.
Return
(
&
blocks
,
nil
)
err
=
client
.
GetBlockSequences
(
rpctypes
.
BlockParam
{},
&
result2
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
1
,
len
(
result2
.
(
*
rpctypes
.
ReplyBlkSeqs
)
.
BlkSeqInfos
))
}
func
TestChain33_GetBlockByHashes
(
t
*
testing
.
T
)
{
api
:=
new
(
mocks
.
QueueProtocolAPI
)
client
:=
newTestChain33
(
api
)
...
...
vendor/github.com/33cn/chain33/rpc/server.go
View file @
3603d6d7
...
...
@@ -12,6 +12,7 @@ import (
"github.com/33cn/chain33/client"
"github.com/33cn/chain33/pluginmgr"
"github.com/33cn/chain33/queue"
"github.com/33cn/chain33/rpc/grpcclient"
_
"github.com/33cn/chain33/rpc/grpcclient"
// register grpc multiple resolver
"github.com/33cn/chain33/types"
"golang.org/x/net/context"
...
...
@@ -33,6 +34,8 @@ var (
// Chain33 a channel client
type
Chain33
struct
{
cli
channelClient
//for communicate with main chain in parallel chain
mainGrpcCli
types
.
Chain33Client
}
// Grpc a channelClient
...
...
@@ -169,6 +172,11 @@ func NewGRpcServer(c queue.Client, api client.QueueProtocolAPI) *Grpcserver {
func
NewJSONRPCServer
(
c
queue
.
Client
,
api
client
.
QueueProtocolAPI
)
*
JSONRPCServer
{
j
:=
&
JSONRPCServer
{
jrpc
:
&
Chain33
{}}
j
.
jrpc
.
cli
.
Init
(
c
,
api
)
grpcCli
,
err
:=
grpcclient
.
NewMainChainClient
(
""
)
if
err
!=
nil
{
panic
(
err
)
}
j
.
jrpc
.
mainGrpcCli
=
grpcCli
server
:=
rpc
.
NewServer
()
j
.
s
=
server
server
.
RegisterName
(
"Chain33"
,
j
.
jrpc
)
...
...
vendor/github.com/33cn/chain33/rpc/server_test.go
View file @
3603d6d7
...
...
@@ -42,7 +42,6 @@ func TestJSONClient_Call(t *testing.T) {
rpcCfg
=
new
(
types
.
RPC
)
rpcCfg
.
GrpcBindAddr
=
"127.0.0.1:8101"
rpcCfg
.
JrpcBindAddr
=
"127.0.0.1:8200"
rpcCfg
.
MainnetJrpcAddr
=
rpcCfg
.
JrpcBindAddr
rpcCfg
.
Whitelist
=
[]
string
{
"127.0.0.1"
,
"0.0.0.0"
}
rpcCfg
.
JrpcFuncWhitelist
=
[]
string
{
"*"
}
rpcCfg
.
GrpcFuncWhitelist
=
[]
string
{
"*"
}
...
...
@@ -146,7 +145,6 @@ func TestGrpc_Call(t *testing.T) {
rpcCfg
=
new
(
types
.
RPC
)
rpcCfg
.
GrpcBindAddr
=
"127.0.0.1:8101"
rpcCfg
.
JrpcBindAddr
=
"127.0.0.1:8200"
rpcCfg
.
MainnetJrpcAddr
=
rpcCfg
.
JrpcBindAddr
rpcCfg
.
Whitelist
=
[]
string
{
"127.0.0.1"
,
"0.0.0.0"
}
rpcCfg
.
JrpcFuncWhitelist
=
[]
string
{
"*"
}
rpcCfg
.
GrpcFuncWhitelist
=
[]
string
{
"*"
}
...
...
vendor/github.com/33cn/chain33/types/cfg.go
View file @
3603d6d7
...
...
@@ -138,7 +138,6 @@ type RPC struct {
GrpcFuncWhitelist
[]
string
`protobuf:"bytes,6,rep,name=grpcFuncWhitelist" json:"grpcFuncWhitelist,omitempty"`
JrpcFuncBlacklist
[]
string
`protobuf:"bytes,7,rep,name=jrpcFuncBlacklist" json:"jrpcFuncBlacklist,omitempty"`
GrpcFuncBlacklist
[]
string
`protobuf:"bytes,8,rep,name=grpcFuncBlacklist" json:"grpcFuncBlacklist,omitempty"`
MainnetJrpcAddr
string
`protobuf:"bytes,9,opt,name=mainnetJrpcAddr" json:"mainnetJrpcAddr,omitempty"`
EnableTLS
bool
`protobuf:"varint,10,opt,name=enableTLS" json:"enableTLS,omitempty"`
EnableTrace
bool
`protobuf:"varint,10,opt,name=enableTrace" json:"enableTrace,omitempty"`
CertFile
string
`protobuf:"varint,11,opt,name=certFile" json:"certFile,omitempty"`
...
...
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