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
52d13650
Commit
52d13650
authored
May 22, 2019
by
linj
Committed by
33cn
May 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix local key prefix
parent
a6d08daa
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
14 deletions
+21
-14
exec.go
plugin/dapp/js/executor/exec.go
+18
-9
exec_del_local.go
plugin/dapp/js/executor/exec_del_local.go
+1
-2
exec_local.go
plugin/dapp/js/executor/exec_local.go
+1
-2
query.go
plugin/dapp/js/executor/query.go
+1
-1
No files found.
plugin/dapp/js/executor/exec.go
View file @
52d13650
package
executor
import
(
"strings"
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types"
ptypes
"github.com/33cn/plugin/plugin/dapp/js/types"
"github.com/33cn/plugin/plugin/dapp/js/types/jsproto"
)
func
(
c
*
js
)
userExecName
(
name
string
)
string
{
execer
:=
types
.
ExecName
(
"user."
+
ptypes
.
JsX
+
"."
+
name
)
if
types
.
IsPara
()
{
execer
=
types
.
GetTitle
()
+
execer
func
(
c
*
js
)
userExecName
(
name
string
,
local
bool
)
string
{
execer
:=
"user."
+
ptypes
.
JsX
+
"."
+
name
if
local
{
execer
=
types
.
ExecName
(
execer
)
}
return
execer
}
func
(
c
*
js
)
chec
h
JsName
(
name
string
)
bool
{
func
(
c
*
js
)
chec
k
JsName
(
name
string
)
bool
{
if
types
.
IsPara
()
{
return
name
==
types
.
GetTitle
()
+
ptypes
.
JsX
}
return
name
==
ptypes
.
JsX
}
func
(
c
*
js
)
checkJsPrefix
(
name
string
)
bool
{
if
types
.
IsPara
()
{
return
strings
.
HasPrefix
(
name
,
types
.
GetTitle
()
+
"user."
+
ptypes
.
JsX
)
}
return
strings
.
HasPrefix
(
name
,
"user."
+
ptypes
.
JsX
)
}
func
(
c
*
js
)
Exec_Create
(
payload
*
jsproto
.
Create
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
err
:=
checkPriv
(
tx
.
From
(),
ptypes
.
JsCreator
,
c
.
GetStateDB
())
if
err
!=
nil
{
return
nil
,
err
}
execer
:=
c
.
userExecName
(
payload
.
Name
)
if
!
c
.
chec
h
JsName
(
string
(
tx
.
Execer
))
{
execer
:=
c
.
userExecName
(
payload
.
Name
,
false
)
if
!
c
.
chec
k
JsName
(
string
(
tx
.
Execer
))
{
return
nil
,
types
.
ErrExecNameNotMatch
}
c
.
prefix
=
types
.
CalcStatePrefix
([]
byte
(
execer
))
...
...
@@ -56,8 +65,8 @@ func (c *js) Exec_Create(payload *jsproto.Create, tx *types.Transaction, index i
}
func
(
c
*
js
)
Exec_Call
(
payload
*
jsproto
.
Call
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
execer
:=
c
.
userExecName
(
payload
.
Name
)
if
!
c
.
chec
hJsName
(
string
(
tx
.
Execer
))
{
execer
:=
c
.
userExecName
(
payload
.
Name
,
false
)
if
!
c
.
chec
kJsPrefix
(
string
(
tx
.
Execer
))
{
return
nil
,
types
.
ErrExecNameNotMatch
}
c
.
prefix
=
types
.
CalcStatePrefix
([]
byte
(
execer
))
...
...
plugin/dapp/js/executor/exec_del_local.go
View file @
52d13650
...
...
@@ -2,7 +2,6 @@ package executor
import
(
"github.com/33cn/chain33/types"
ptypes
"github.com/33cn/plugin/plugin/dapp/js/types"
"github.com/33cn/plugin/plugin/dapp/js/types/jsproto"
)
...
...
@@ -11,7 +10,7 @@ func (c *js) ExecDelLocal_Create(payload *jsproto.Create, tx *types.Transaction,
}
func
(
c
*
js
)
ExecDelLocal_Call
(
payload
*
jsproto
.
Call
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
execer
:=
types
.
ExecName
(
"user."
+
ptypes
.
JsX
+
"."
+
payload
.
Nam
e
)
execer
:=
c
.
userExecName
(
payload
.
Name
,
tru
e
)
r
:=
&
types
.
LocalDBSet
{}
c
.
prefix
=
types
.
CalcLocalPrefix
([]
byte
(
execer
))
kvs
,
err
:=
c
.
DelRollbackKV
(
tx
,
[]
byte
(
execer
))
...
...
plugin/dapp/js/executor/exec_local.go
View file @
52d13650
...
...
@@ -2,7 +2,6 @@ package executor
import
(
"github.com/33cn/chain33/types"
ptypes
"github.com/33cn/plugin/plugin/dapp/js/types"
"github.com/33cn/plugin/plugin/dapp/js/types/jsproto"
)
...
...
@@ -11,7 +10,7 @@ func (c *js) ExecLocal_Create(payload *jsproto.Create, tx *types.Transaction, re
}
func
(
c
*
js
)
ExecLocal_Call
(
payload
*
jsproto
.
Call
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
execer
:=
types
.
ExecName
(
"user."
+
ptypes
.
JsX
+
"."
+
payload
.
Nam
e
)
execer
:=
c
.
userExecName
(
payload
.
Name
,
tru
e
)
c
.
prefix
=
types
.
CalcLocalPrefix
([]
byte
(
execer
))
jsvalue
,
err
:=
c
.
callVM
(
"execlocal"
,
payload
,
tx
,
index
,
receiptData
)
if
err
!=
nil
{
...
...
plugin/dapp/js/executor/query.go
View file @
52d13650
...
...
@@ -8,7 +8,7 @@ import (
)
func
(
c
*
js
)
Query_Query
(
payload
*
jsproto
.
Call
)
(
types
.
Message
,
error
)
{
execer
:=
c
.
userExecName
(
payload
.
Name
)
execer
:=
c
.
userExecName
(
payload
.
Name
,
true
)
c
.
prefix
=
types
.
CalcLocalPrefix
([]
byte
(
execer
))
jsvalue
,
err
:=
c
.
callVM
(
"query"
,
payload
,
nil
,
0
,
nil
)
if
err
!=
nil
{
...
...
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