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
111fa51a
Commit
111fa51a
authored
Sep 23, 2019
by
pengjun
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master'
parents
5b9088ef
3852934c
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
55 additions
and
23 deletions
+55
-23
go.mod
go.mod
+0
-2
test-rpc.sh
plugin/dapp/paracross/cmd/test/test-rpc.sh
+0
-0
test-rpc.sh
plugin/dapp/retrieve/cmd/build/test-rpc.sh
+0
-0
retrieve.go
plugin/dapp/retrieve/cmd/retrieve.go
+9
-2
exec_del_local.go
plugin/dapp/retrieve/executor/exec_del_local.go
+1
-1
exec_local.go
plugin/dapp/retrieve/executor/exec_local.go
+1
-1
query.go
plugin/dapp/retrieve/executor/query.go
+2
-11
retrievedb.go
plugin/dapp/retrieve/executor/retrievedb.go
+2
-2
retrieve.proto
plugin/dapp/retrieve/proto/retrieve.proto
+7
-1
jrpc.go
plugin/dapp/retrieve/rpc/jrpc.go
+5
-0
jrpc_channel_test.go
plugin/dapp/retrieve/rpc/jrpc_channel_test.go
+25
-2
rpc.go
plugin/dapp/retrieve/rpc/rpc.go
+3
-1
retrieve.pb.go
plugin/dapp/retrieve/types/retrieve.pb.go
+0
-0
No files found.
go.mod
View file @
111fa51a
...
@@ -20,8 +20,6 @@ require (
...
@@ -20,8 +20,6 @@ require (
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3
github.com/golang/protobuf v1.3.2
github.com/golang/protobuf v1.3.2
github.com/hashicorp/golang-lru v0.5.0
github.com/hashicorp/golang-lru v0.5.0
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/pkg/errors v0.8.0
github.com/pkg/errors v0.8.0
github.com/prometheus/client_golang v1.1.0 // indirect
github.com/prometheus/client_golang v1.1.0 // indirect
github.com/robertkrimen/otto v0.0.0-20180617131154-15f95af6e78d
github.com/robertkrimen/otto v0.0.0-20180617131154-15f95af6e78d
...
...
plugin/dapp/paracross/cmd/test/test-rpc.sh
View file @
111fa51a
This diff is collapsed.
Click to expand it.
plugin/dapp/retrieve/cmd/build/test-rpc.sh
View file @
111fa51a
This diff is collapsed.
Click to expand it.
plugin/dapp/retrieve/cmd/retrieve.go
View file @
111fa51a
...
@@ -168,7 +168,7 @@ func performCmd(cmd *cobra.Command, args []string) {
...
@@ -168,7 +168,7 @@ func performCmd(cmd *cobra.Command, args []string) {
return
return
}
}
for
i
:=
0
;
i
<
len
(
execs
);
i
++
{
for
i
:=
0
;
i
<
len
(
execs
);
i
++
{
params
.
Assets
=
append
(
params
.
Assets
,
rpc
.
Asset
{
Exec
:
execs
[
i
],
Symbol
:
symbols
[
0
]})
params
.
Assets
=
append
(
params
.
Assets
,
rpc
.
Asset
{
Exec
:
execs
[
i
],
Symbol
:
symbols
[
i
]})
}
}
ctx
:=
jsonrpc
.
NewRPCCtx
(
rpcLaddr
,
"retrieve.CreateRawRetrievePerformTx"
,
params
,
nil
)
ctx
:=
jsonrpc
.
NewRPCCtx
(
rpcLaddr
,
"retrieve.CreateRawRetrievePerformTx"
,
params
,
nil
)
...
@@ -206,7 +206,7 @@ func cancelCmd(cmd *cobra.Command, args []string) {
...
@@ -206,7 +206,7 @@ func cancelCmd(cmd *cobra.Command, args []string) {
func
RetrieveQueryCmd
()
*
cobra
.
Command
{
func
RetrieveQueryCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"query"
,
Use
:
"query"
,
Short
:
"
Backup the wallet
"
,
Short
:
"
show retrieve info
"
,
Run
:
queryRetrieveCmd
,
Run
:
queryRetrieveCmd
,
}
}
addQueryRetrieveCmdFlags
(
cmd
)
addQueryRetrieveCmdFlags
(
cmd
)
...
@@ -218,6 +218,9 @@ func addQueryRetrieveCmdFlags(cmd *cobra.Command) {
...
@@ -218,6 +218,9 @@ func addQueryRetrieveCmdFlags(cmd *cobra.Command) {
cmd
.
MarkFlagRequired
(
"backup"
)
cmd
.
MarkFlagRequired
(
"backup"
)
cmd
.
Flags
()
.
StringP
(
"default"
,
"t"
,
""
,
"default address"
)
cmd
.
Flags
()
.
StringP
(
"default"
,
"t"
,
""
,
"default address"
)
cmd
.
MarkFlagRequired
(
"default"
)
cmd
.
MarkFlagRequired
(
"default"
)
cmd
.
Flags
()
.
StringP
(
"asset_exec"
,
"e"
,
""
,
"asset exec"
)
cmd
.
Flags
()
.
StringP
(
"asset_symbol"
,
"s"
,
""
,
"asset symbol"
)
}
}
func
parseRerieveDetail
(
arg
interface
{})
(
interface
{},
error
)
{
func
parseRerieveDetail
(
arg
interface
{})
(
interface
{},
error
)
{
...
@@ -246,10 +249,14 @@ func queryRetrieveCmd(cmd *cobra.Command, args []string) {
...
@@ -246,10 +249,14 @@ func queryRetrieveCmd(cmd *cobra.Command, args []string) {
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
backup
,
_
:=
cmd
.
Flags
()
.
GetString
(
"backup"
)
backup
,
_
:=
cmd
.
Flags
()
.
GetString
(
"backup"
)
defaultAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"default"
)
defaultAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"default"
)
exec
,
_
:=
cmd
.
Flags
()
.
GetString
(
"asset_exec"
)
symbol
,
_
:=
cmd
.
Flags
()
.
GetString
(
"asset_symbol"
)
req
:=
&
rt
.
ReqRetrieveInfo
{
req
:=
&
rt
.
ReqRetrieveInfo
{
BackupAddress
:
backup
,
BackupAddress
:
backup
,
DefaultAddress
:
defaultAddr
,
DefaultAddress
:
defaultAddr
,
AssetExec
:
exec
,
AssetSymbol
:
symbol
,
}
}
var
params
rpctypes
.
Query4Jrpc
var
params
rpctypes
.
Query4Jrpc
...
...
plugin/dapp/retrieve/executor/exec_del_local.go
View file @
111fa51a
...
@@ -97,7 +97,7 @@ func (c *Retrieve) ExecDelLocal_Perform(perf *rt.PerformRetrieve, tx *types.Tran
...
@@ -97,7 +97,7 @@ func (c *Retrieve) ExecDelLocal_Perform(perf *rt.PerformRetrieve, tx *types.Tran
if
types
.
IsDappFork
(
c
.
GetHeight
(),
rt
.
RetrieveX
,
rt
.
ForkRetriveAssetX
)
{
if
types
.
IsDappFork
(
c
.
GetHeight
(),
rt
.
RetrieveX
,
rt
.
ForkRetriveAssetX
)
{
if
len
(
perf
.
Assets
)
==
0
{
if
len
(
perf
.
Assets
)
==
0
{
perf
.
Assets
=
append
(
perf
.
Assets
,
&
types
.
Asset
{
Exec
:
"coins"
,
Symbol
:
types
.
GetCoinSymbol
()})
perf
.
Assets
=
append
(
perf
.
Assets
,
&
rt
.
AssetSymbol
{
Exec
:
"coins"
,
Symbol
:
types
.
GetCoinSymbol
()})
}
}
}
}
for
_
,
asset
:=
range
perf
.
Assets
{
for
_
,
asset
:=
range
perf
.
Assets
{
...
...
plugin/dapp/retrieve/executor/exec_local.go
View file @
111fa51a
...
@@ -104,7 +104,7 @@ func (c *Retrieve) ExecLocal_Perform(perf *rt.PerformRetrieve, tx *types.Transac
...
@@ -104,7 +104,7 @@ func (c *Retrieve) ExecLocal_Perform(perf *rt.PerformRetrieve, tx *types.Transac
}
}
if
types
.
IsDappFork
(
c
.
GetHeight
(),
rt
.
RetrieveX
,
rt
.
ForkRetriveAssetX
)
{
if
types
.
IsDappFork
(
c
.
GetHeight
(),
rt
.
RetrieveX
,
rt
.
ForkRetriveAssetX
)
{
if
len
(
perf
.
Assets
)
==
0
{
if
len
(
perf
.
Assets
)
==
0
{
perf
.
Assets
=
append
(
perf
.
Assets
,
&
types
.
Asset
{
Exec
:
"coins"
,
Symbol
:
types
.
GetCoinSymbol
()})
perf
.
Assets
=
append
(
perf
.
Assets
,
&
rt
.
AssetSymbol
{
Exec
:
"coins"
,
Symbol
:
types
.
GetCoinSymbol
()})
}
}
}
}
for
_
,
asset
:=
range
perf
.
Assets
{
for
_
,
asset
:=
range
perf
.
Assets
{
...
...
plugin/dapp/retrieve/executor/query.go
View file @
111fa51a
...
@@ -5,8 +5,6 @@
...
@@ -5,8 +5,6 @@
package
executor
package
executor
import
(
import
(
"fmt"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
rt
"github.com/33cn/plugin/plugin/dapp/retrieve/types"
rt
"github.com/33cn/plugin/plugin/dapp/retrieve/types"
)
)
...
@@ -29,11 +27,9 @@ func (r *Retrieve) Query_GetRetrieveInfo(in *rt.ReqRetrieveInfo) (types.Message,
...
@@ -29,11 +27,9 @@ func (r *Retrieve) Query_GetRetrieveInfo(in *rt.ReqRetrieveInfo) (types.Message,
if
info
.
Status
==
retrievePerform
&&
in
.
GetAssetExec
()
!=
""
{
if
info
.
Status
==
retrievePerform
&&
in
.
GetAssetExec
()
!=
""
{
// retrievePerform状态下,不存在有两种情况
// retrievePerform状态下,不存在有两种情况
// 1 还没找回, 2 fork 之前是没有coins 找回记录的
// 1 还没找回, 2 fork 之前是没有coins 找回记录的
count
:=
r
.
GetLocalDB
()
.
PrefixCount
(
calcRetrieveAssetPrefix
(
in
.
BackupAddress
,
in
.
DefaultAddress
))
// 2 fork 之前是 没有coins 找回记录的, 相当于都找回了
// 2 fork 之前是 没有coins 找回记录的, 相当于都找回了
if
count
==
0
{
// localdb not support PrefixCount
return
info
,
nil
// 所以在填写具体资产的情况下, 认为是要找对应的资产
}
asset
,
_
:=
getRetrieveAsset
(
r
.
GetLocalDB
(),
in
.
BackupAddress
,
in
.
DefaultAddress
,
in
.
AssetExec
,
in
.
AssetSymbol
)
asset
,
_
:=
getRetrieveAsset
(
r
.
GetLocalDB
(),
in
.
BackupAddress
,
in
.
DefaultAddress
,
in
.
AssetExec
,
in
.
AssetSymbol
)
if
asset
!=
nil
{
if
asset
!=
nil
{
...
@@ -48,8 +44,3 @@ func (r *Retrieve) Query_GetRetrieveInfo(in *rt.ReqRetrieveInfo) (types.Message,
...
@@ -48,8 +44,3 @@ func (r *Retrieve) Query_GetRetrieveInfo(in *rt.ReqRetrieveInfo) (types.Message,
}
}
return
info
,
nil
return
info
,
nil
}
}
func
calcRetrieveAssetPrefix
(
backupAddr
,
defaultAddr
string
)
[]
byte
{
key
:=
fmt
.
Sprintf
(
"LODB-retrieve-backup-asset:%s:%s:"
,
backupAddr
,
defaultAddr
)
return
[]
byte
(
key
)
}
plugin/dapp/retrieve/executor/retrievedb.go
View file @
111fa51a
...
@@ -211,7 +211,7 @@ func (action *Action) RetrievePerformAssets(perfRet *rt.PerformRetrieve, default
...
@@ -211,7 +211,7 @@ func (action *Action) RetrievePerformAssets(perfRet *rt.PerformRetrieve, default
// 兼容原来的找回, 在不指定的情况下,找回主币
// 兼容原来的找回, 在不指定的情况下,找回主币
if
len
(
perfRet
.
Assets
)
==
0
{
if
len
(
perfRet
.
Assets
)
==
0
{
perfRet
.
Assets
=
append
(
perfRet
.
Assets
,
&
types
.
Asset
{
Exec
:
"coins"
,
Symbol
:
types
.
GetCoinSymbol
()})
perfRet
.
Assets
=
append
(
perfRet
.
Assets
,
&
rt
.
AssetSymbol
{
Exec
:
"coins"
,
Symbol
:
types
.
GetCoinSymbol
()})
//return nil, nil
//return nil, nil
}
}
...
@@ -224,7 +224,7 @@ func (action *Action) RetrievePerformAssets(perfRet *rt.PerformRetrieve, default
...
@@ -224,7 +224,7 @@ func (action *Action) RetrievePerformAssets(perfRet *rt.PerformRetrieve, default
acc
:=
accdb
.
LoadExecAccount
(
defaultAddress
,
action
.
execaddr
)
acc
:=
accdb
.
LoadExecAccount
(
defaultAddress
,
action
.
execaddr
)
rlog
.
Debug
(
"RetrievePerform"
,
"acc.Balance"
,
acc
.
Balance
)
rlog
.
Debug
(
"RetrievePerform"
,
"acc.Balance"
,
acc
.
Balance
)
if
acc
.
Balance
>
0
{
if
acc
.
Balance
>
0
{
receipt
,
err
=
ac
tion
.
coinsAccount
.
ExecTransfer
(
defaultAddress
,
perfRet
.
BackupAddress
,
action
.
execaddr
,
acc
.
Balance
)
receipt
,
err
=
ac
cdb
.
ExecTransfer
(
defaultAddress
,
perfRet
.
BackupAddress
,
action
.
execaddr
,
acc
.
Balance
)
if
err
!=
nil
{
if
err
!=
nil
{
rlog
.
Debug
(
"RetrievePerform"
,
"ExecTransfer"
,
err
)
rlog
.
Debug
(
"RetrievePerform"
,
"ExecTransfer"
,
err
)
return
nil
,
err
return
nil
,
err
...
...
plugin/dapp/retrieve/proto/retrieve.proto
View file @
111fa51a
...
@@ -40,10 +40,16 @@ message PrepareRetrieve {
...
@@ -40,10 +40,16 @@ message PrepareRetrieve {
string
defaultAddress
=
2
;
string
defaultAddress
=
2
;
}
}
message
AssetSymbol
{
string
exec
=
1
;
string
symbol
=
2
;
}
message
PerformRetrieve
{
message
PerformRetrieve
{
string
backupAddress
=
1
;
string
backupAddress
=
1
;
string
defaultAddress
=
2
;
string
defaultAddress
=
2
;
repeated
Asset
assets
=
3
;
repeated
Asset
Symbol
assets
=
3
;
}
}
message
CancelRetrieve
{
message
CancelRetrieve
{
...
...
plugin/dapp/retrieve/rpc/jrpc.go
View file @
111fa51a
...
@@ -49,6 +49,11 @@ func (c *Jrpc) CreateRawRetrievePerformTx(in *RetrievePerformTx, result *interfa
...
@@ -49,6 +49,11 @@ func (c *Jrpc) CreateRawRetrievePerformTx(in *RetrievePerformTx, result *interfa
head
:=
&
types
.
PerformRetrieve
{
head
:=
&
types
.
PerformRetrieve
{
BackupAddress
:
in
.
BackupAddr
,
BackupAddress
:
in
.
BackupAddr
,
DefaultAddress
:
in
.
DefaultAddr
,
DefaultAddress
:
in
.
DefaultAddr
,
Assets
:
[]
*
types
.
AssetSymbol
{},
}
for
i
:=
0
;
i
<
len
(
in
.
Assets
);
i
++
{
head
.
Assets
=
append
(
head
.
Assets
,
&
types
.
AssetSymbol
{
Exec
:
in
.
Assets
[
i
]
.
Exec
,
Symbol
:
in
.
Assets
[
i
]
.
Symbol
})
}
}
reply
,
err
:=
c
.
cli
.
Perform
(
context
.
Background
(),
head
)
reply
,
err
:=
c
.
cli
.
Perform
(
context
.
Background
(),
head
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
plugin/dapp/retrieve/rpc/jrpc_channel_test.go
View file @
111fa51a
...
@@ -8,11 +8,14 @@ import (
...
@@ -8,11 +8,14 @@ import (
"strings"
"strings"
"testing"
"testing"
"github.com/33cn/chain33/common"
commonlog
"github.com/33cn/chain33/common/log"
commonlog
"github.com/33cn/chain33/common/log"
"github.com/33cn/chain33/rpc/jsonclient"
"github.com/33cn/chain33/rpc/jsonclient"
rpctypes
"github.com/33cn/chain33/rpc/types"
rpctypes
"github.com/33cn/chain33/rpc/types"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/util/testnode"
"github.com/33cn/chain33/util/testnode"
"github.com/33cn/plugin/plugin/dapp/retrieve/rpc"
"github.com/33cn/plugin/plugin/dapp/retrieve/rpc"
pty
"github.com/33cn/plugin/plugin/dapp/retrieve/types"
pty
"github.com/33cn/plugin/plugin/dapp/retrieve/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
...
@@ -67,8 +70,28 @@ func testPrepareCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
...
@@ -67,8 +70,28 @@ func testPrepareCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
}
}
func
testPerformCmd
(
t
*
testing
.
T
,
jrpc
*
jsonclient
.
JSONClient
)
error
{
func
testPerformCmd
(
t
*
testing
.
T
,
jrpc
*
jsonclient
.
JSONClient
)
error
{
params
:=
rpc
.
RetrievePerformTx
{}
params
:=
rpc
.
RetrievePerformTx
{
return
jrpc
.
Call
(
"retrieve.CreateRawRetrievePerformTx"
,
params
,
nil
)
BackupAddr
:
"b"
,
DefaultAddr
:
"d"
,
Assets
:
[]
rpc
.
Asset
{{
"e"
,
"s"
}},
}
var
txS
string
t
.
Log
(
"tx info"
,
"x"
,
params
.
Assets
)
err
:=
jrpc
.
Call
(
"retrieve.CreateRawRetrievePerformTx"
,
&
params
,
&
txS
)
var
tx
types
.
Transaction
bytes
,
err
:=
common
.
FromHex
(
txS
)
if
err
!=
nil
{
return
err
}
err
=
types
.
Decode
(
bytes
,
&
tx
)
if
err
!=
nil
{
return
err
}
var
p2
pty
.
RetrieveAction
err
=
types
.
Decode
(
tx
.
Payload
,
&
p2
)
t
.
Log
(
"asset"
,
p2
.
GetPerform
()
.
GetAssets
())
return
err
}
}
func
testCancelCmd
(
t
*
testing
.
T
,
jrpc
*
jsonclient
.
JSONClient
)
error
{
func
testCancelCmd
(
t
*
testing
.
T
,
jrpc
*
jsonclient
.
JSONClient
)
error
{
...
...
plugin/dapp/retrieve/rpc/rpc.go
View file @
111fa51a
...
@@ -43,10 +43,12 @@ func (c *channelClient) Perform(ctx context.Context, v *rt.PerformRetrieve) (*ty
...
@@ -43,10 +43,12 @@ func (c *channelClient) Perform(ctx context.Context, v *rt.PerformRetrieve) (*ty
Ty
:
rt
.
RetrieveActionPerform
,
Ty
:
rt
.
RetrieveActionPerform
,
Value
:
&
rt
.
RetrieveAction_Perform
{
Perform
:
v
},
Value
:
&
rt
.
RetrieveAction_Perform
{
Perform
:
v
},
}
}
tx
,
err
:=
types
.
CreateFormatTx
(
types
.
ExecName
(
rt
.
RetrieveX
),
types
.
Encode
(
perform
))
payload
:=
types
.
Encode
(
perform
)
tx
,
err
:=
types
.
CreateFormatTx
(
types
.
ExecName
(
rt
.
RetrieveX
),
payload
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
data
:=
types
.
Encode
(
tx
)
data
:=
types
.
Encode
(
tx
)
return
&
types
.
UnsignTx
{
Data
:
data
},
nil
return
&
types
.
UnsignTx
{
Data
:
data
},
nil
}
}
...
...
plugin/dapp/retrieve/types/retrieve.pb.go
View file @
111fa51a
This diff is collapsed.
Click to expand it.
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