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
1c63009b
Unverified
Commit
1c63009b
authored
Sep 24, 2019
by
vipwzw
Committed by
GitHub
Sep 24, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #643 from linj-disanbo/fix-retrieve
Fix retrieve
parents
3defc781
506a3b92
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
56 additions
and
22 deletions
+56
-22
dapp-test-rpc.sh
build/dapp-test-rpc.sh
+1
-1
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.
build/dapp-test-rpc.sh
View file @
1c63009b
...
@@ -11,7 +11,7 @@ function dapp_test_rpc() {
...
@@ -11,7 +11,7 @@ function dapp_test_rpc() {
cp
$DAPP_TEST_COMMON
dapptest/
cp
$DAPP_TEST_COMMON
dapptest/
cd
dapptest
||
return
cd
dapptest
||
return
dir
=
$(
find
.
-maxdepth
1
-type
d
!
-name
dapptest
!
-name
evm
!
-name
game
!
-name
guess
!
-name
hashlock
!
-name
ticket
!
-name
lottery
!
-name
pokerbull
!
-name
retrieve
!
-name
token
!
-name
trade
!
-name
.
|
sed
's/^\.\///'
|
sort
)
dir
=
$(
find
.
-maxdepth
1
-type
d
!
-name
dapptest
!
-name
evm
!
-name
game
!
-name
guess
!
-name
hashlock
!
-name
ticket
!
-name
lottery
!
-name
pokerbull
!
-name
token
!
-name
trade
!
-name
.
|
sed
's/^\.\///'
|
sort
)
echo
"dapps list:
$dir
"
echo
"dapps list:
$dir
"
for
app
in
$dir
;
do
for
app
in
$dir
;
do
...
...
plugin/dapp/retrieve/cmd/build/test-rpc.sh
View file @
1c63009b
This diff is collapsed.
Click to expand it.
plugin/dapp/retrieve/cmd/retrieve.go
View file @
1c63009b
...
@@ -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 @
1c63009b
...
@@ -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 @
1c63009b
...
@@ -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 @
1c63009b
...
@@ -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 @
1c63009b
...
@@ -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 @
1c63009b
...
@@ -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 @
1c63009b
...
@@ -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 @
1c63009b
...
@@ -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 @
1c63009b
...
@@ -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 @
1c63009b
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