Skip to content

Commit

Permalink
fix internal state bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Musiczombie committed Jan 4, 2020
1 parent 8486b65 commit 173c869
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 19 deletions.
10 changes: 5 additions & 5 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
browser:
mysql:
user: root
password: 12345678
ip: localhost
password: Bochen@123
ip: 192.168.1.12
port: 3306
database: ft
database: mft
node:
rpcHost: http://192.168.1.12:11000
rpcHost: http://192.168.1.12:2201
log:
level: info #error info debug
file:
Expand All @@ -15,7 +15,7 @@ browser:
rotationTime: 1 #time.Duration 1:day 2:hour
maxAge: 15 #day
console: true
syncBlockShowNumber: 1
syncBlockShowNumber: 100
tasks:
- block
- txs
Expand Down
4 changes: 4 additions & 0 deletions data.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
t,u,ftoken,fractal.founder,fractal.account,mapping
t,h,ftoken,mapping,support,fractal.founder,fractal.account
c,u,fractal.asset,
c,u,fractal.account,,fractal,fractal.founder
12 changes: 7 additions & 5 deletions task/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ func (a *AccountTask) analysisAccount(data *types.BlockAndResult, dbTx *sql.Tx)
if containsInternalTxs {
internalActions := detailTxs[i].InternalActions[j]
for _, iat := range internalActions.InternalLogs {
if iat.Error != "" {
if iat.Error == "" {
err := a.ActionToAccount(iat.Action, dbTx, data.Block, oldAccounts)
if err != nil {
ZapLog.Error("ActionToAccount error: ", zap.Error(err))
Expand Down Expand Up @@ -370,10 +370,12 @@ func (a *AccountTask) rollback(data *types.BlockAndResult, dbTx *sql.Tx) error {
if len(detailTxs) != 0 {
internalActions := detailTxs[i].InternalActions[j]
for _, iat := range internalActions.InternalLogs {
err := a.rollbackAccount(iat.Action, dbTx, deleteAccounts)
if err != nil {
ZapLog.Error("rollbackAccount error:", zap.Error(err))
return err
if iat.Error == ""{
err := a.rollbackAccount(iat.Action, dbTx, deleteAccounts)
if err != nil {
ZapLog.Error("rollbackAccount error:", zap.Error(err))
return err
}
}
}
}
Expand Down
14 changes: 8 additions & 6 deletions task/balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (b *BalanceTask) analysisBalance(data *types.BlockAndResult, dbTx *sql.Tx)
if len(detailTxs) != 0 {
internalActions := detailTxs[i].InternalActions[j]
for _, iat := range internalActions.InternalLogs {
if iat.Error != "" {
if iat.Error == "" {
if iat.Action.From.String() != "" {
changeBalance(balanceChangedMap, iat.Action.From.String(), iat.Action.AssetID, iat.Action.Amount, false)
}
Expand Down Expand Up @@ -220,11 +220,13 @@ func (b *BalanceTask) rollback(data *types.BlockAndResult, dbTx *sql.Tx) error {
if len(detailTxs) != 0 {
internalActions := detailTxs[i].InternalActions[j]
for _, iat := range internalActions.InternalLogs {
if iat.Action.To.String() != "" {
changeBalance(balanceChangedMap, iat.Action.To.String(), iat.Action.AssetID, iat.Action.Amount, false)
}
if iat.Action.From.String() != "" {
changeBalance(balanceChangedMap, iat.Action.From.String(), iat.Action.AssetID, iat.Action.Amount, true)
if iat.Error == "" {
if iat.Action.To.String() != "" {
changeBalance(balanceChangedMap, iat.Action.To.String(), iat.Action.AssetID, iat.Action.Amount, false)
}
if iat.Action.From.String() != "" {
changeBalance(balanceChangedMap, iat.Action.From.String(), iat.Action.AssetID, iat.Action.Amount, true)
}
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions task/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (t *TokenTask) analysisToken(block *TaskChanData) {
for _, action := range tx.InternalActions {
//if receipts[i].ActionResults[j].Status == types.ReceiptStatusSuccessful {
for _, internalLog := range action.InternalLogs {
if internalLog.Error != "" {
if internalLog.Error == "" {
if t.isTokenTxs(internalLog.Action.Type) {
isbackup := 0
if types.IssueAsset != internalLog.Action.Type {
Expand Down Expand Up @@ -135,8 +135,10 @@ func (t *TokenTask) rollback(block *TaskChanData) {
for j, action := range tx.InternalActions {
if receipts[i].ActionResults[j].Status == types.ReceiptStatusSuccessful {
for _, internalLog := range action.InternalLogs {
if t.isTokenTxs(internalLog.Action.Type) {
rollbackToken(block.Tx, internalLog.Action, block.Block.Block.Time, block.Block.Block.Number.Uint64())
if internalLog.Error == "" {
if t.isTokenTxs(internalLog.Action.Type) {
rollbackToken(block.Tx, internalLog.Action, block.Block.Block.Time, block.Block.Block.Number.Uint64())
}
}
}
}
Expand Down

0 comments on commit 173c869

Please sign in to comment.