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
0559134e
Commit
0559134e
authored
Mar 19, 2021
by
jiangpeng
Committed by
vipwzw
Mar 24, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
privacy:update privacy tx storing
* add pub2priv tx db index * refactor add del block tx in wallet
parent
22f27b21
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
34 deletions
+31
-34
privacy.go
plugin/dapp/privacy/wallet/privacy.go
+0
-0
privacy_test.go
plugin/dapp/privacy/wallet/privacy_test.go
+1
-1
privacybizpolicy.go
plugin/dapp/privacy/wallet/privacybizpolicy.go
+20
-10
privacystore.go
plugin/dapp/privacy/wallet/privacystore.go
+7
-15
privacystore_test.go
plugin/dapp/privacy/wallet/privacystore_test.go
+3
-8
No files found.
plugin/dapp/privacy/wallet/privacy.go
View file @
0559134e
This diff is collapsed.
Click to expand it.
plugin/dapp/privacy/wallet/privacy_test.go
View file @
0559134e
...
...
@@ -181,7 +181,7 @@ func (mock *PrivacyMock) CreateUTXOs(sender string, pubkeypair string, amount in
}
utxos
=
append
(
utxos
,
utxoCreated
)
mock
.
store
.
setUTXO
(
info
.
Addr
,
&
txhashstr
,
indexoutput
,
info2store
,
dbbatch
)
mock
.
store
.
setUTXO
(
info
2store
,
txhashstr
,
dbbatch
)
}
}
}
...
...
plugin/dapp/privacy/wallet/privacybizpolicy.go
View file @
0559134e
...
...
@@ -170,18 +170,28 @@ func (policy *privacyPolicy) SignTransaction(key crypto.PrivKey, req *types.ReqS
return
}
type
buildStoreWalletTxDetailParam
struct
{
assetExec
string
tokenname
string
block
*
types
.
BlockDetail
type
privacyTxInfo
struct
{
tx
*
types
.
Transaction
index
int
newbatch
db
.
Batch
senderRecver
string
isprivacy
bool
addDelType
int32
blockDetail
*
types
.
BlockDetail
actionTy
int32
actionName
string
input
*
privacytypes
.
PrivacyInput
output
*
privacytypes
.
PrivacyOutput
txIndex
int32
blockHeight
int64
isExecOk
bool
isRollBack
bool
txHash
[]
byte
txHashHex
string
assetExec
string
assetSymbol
string
batch
db
.
Batch
}
type
buildStoreWalletTxDetailParam
struct
{
txInfo
*
privacyTxInfo
addr
string
sendRecvFlag
int32
utxos
[]
*
privacytypes
.
UTXO
}
// OnAddBlockTx 响应区块交易添加的处理
...
...
plugin/dapp/privacy/wallet/privacystore.go
View file @
0559134e
...
...
@@ -642,7 +642,7 @@ func (store *privacyStore) selectCurrentWalletPrivacyTx(txDetal *types.Transacti
}
utxos
=
append
(
utxos
,
utxoCreated
)
store
.
setUTXO
(
info
.
Addr
,
&
txhash
,
indexoutput
,
info2store
,
newbatch
)
store
.
setUTXO
(
info
2store
,
txhash
,
newbatch
)
}
}
}
...
...
@@ -671,25 +671,17 @@ func (store *privacyStore) selectCurrentWalletPrivacyTx(txDetal *types.Transacti
//UTXO---->moveUTXO2FTXO---->FTXO---->moveFTXO2STXO---->STXO
//1.calcUTXOKey------------>types.PrivacyDBStore 该kv值在db中的存储一旦写入就不再改变,除非产生该UTXO的交易被撤销
//2.calcUTXOKey4TokenAddr-->calcUTXOKey,创建kv,方便查询现在某个地址下某种token的可用utxo
func
(
store
*
privacyStore
)
setUTXO
(
addr
,
txhash
*
string
,
outindex
int
,
dbStore
*
privacytypes
.
PrivacyDBStore
,
newbatch
db
.
Batch
)
error
{
if
0
==
len
(
*
addr
)
||
0
==
len
(
*
txhash
)
{
bizlog
.
Error
(
"setUTXO addr or txhash is nil"
)
return
types
.
ErrInvalidParam
}
if
dbStore
==
nil
{
bizlog
.
Error
(
"setUTXO privacy is nil"
)
return
types
.
ErrInvalidParam
}
func
(
store
*
privacyStore
)
setUTXO
(
utxoInfo
*
privacytypes
.
PrivacyDBStore
,
txHash
string
,
newbatch
db
.
Batch
)
error
{
privacyStorebyte
,
err
:=
proto
.
Marshal
(
dbStore
)
privacyStorebyte
,
err
:=
proto
.
Marshal
(
utxoInfo
)
if
err
!=
nil
{
bizlog
.
Error
(
"setUTXO proto.Marshal err!"
,
"err"
,
err
)
return
types
.
ErrMarshal
}
utxoKey
:=
calcUTXOKey
(
*
txhash
,
outi
ndex
)
bizlog
.
Debug
(
"setUTXO"
,
"addr"
,
*
addr
,
"tx with hash"
,
*
txhash
,
"amount:"
,
dbStore
.
Amount
/
types
.
Coin
)
newbatch
.
Set
(
calcUTXOKey4TokenAddr
(
dbStore
.
AssetExec
,
dbStore
.
Tokenname
,
*
addr
,
*
txhash
,
outi
ndex
),
utxoKey
)
outIndex
:=
int
(
utxoInfo
.
OutIndex
)
utxoKey
:=
calcUTXOKey
(
txHash
,
outI
ndex
)
bizlog
.
Debug
(
"setUTXO"
,
"addr"
,
utxoInfo
.
Owner
,
"tx with hash"
,
txHash
,
"amount:"
,
utxoInfo
.
Amount
/
types
.
Coin
)
newbatch
.
Set
(
calcUTXOKey4TokenAddr
(
utxoInfo
.
AssetExec
,
utxoInfo
.
Tokenname
,
utxoInfo
.
Owner
,
txHash
,
outI
ndex
),
utxoKey
)
newbatch
.
Set
(
utxoKey
,
privacyStorebyte
)
return
nil
}
...
...
plugin/dapp/privacy/wallet/privacystore_test.go
View file @
0559134e
...
...
@@ -117,16 +117,11 @@ func testStore_storeScanPrivacyInputUTXO(t *testing.T) {
}
func
testStore_setUTXO
(
t
*
testing
.
T
)
{
var
addr
,
txhash
string
var
txhash
string
store
:=
createStore
(
t
)
dbbatch
:=
store
.
NewBatch
(
true
)
err
:=
store
.
setUTXO
(
&
addr
,
&
txhash
,
0
,
nil
,
dbbatch
)
assert
.
NotNil
(
t
,
err
)
addr
=
"setUTXO"
txhash
=
"TXHASH"
err
=
store
.
setUTXO
(
&
addr
,
&
txhash
,
0
,
nil
,
dbbatch
)
assert
.
NotNil
(
t
,
err
)
err
:=
store
.
setUTXO
(
&
pt
.
PrivacyDBStore
{},
txhash
,
dbbatch
)
assert
.
Nil
(
t
,
err
)
}
func
testStore_selectPrivacyTransactionToWallet
(
t
*
testing
.
T
)
{
...
...
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