core: simplify GetTransationResults() based on golint suggestion
Golint: pkg/core/blockchain.go:796:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) Refs. #213.
This commit is contained in:
parent
0c160a81fe
commit
89ed00ddfb
1 changed files with 31 additions and 33 deletions
|
@ -791,43 +791,41 @@ func (bc *Blockchain) GetTransationResults(t *transaction.Transaction) []*transa
|
||||||
var results []*transaction.Result
|
var results []*transaction.Result
|
||||||
tempGroupResult := make(map[util.Uint256]util.Fixed8)
|
tempGroupResult := make(map[util.Uint256]util.Fixed8)
|
||||||
|
|
||||||
if references := bc.References(t); references == nil {
|
references := bc.References(t)
|
||||||
|
if references == nil {
|
||||||
return nil
|
return nil
|
||||||
} else {
|
}
|
||||||
for _, output := range references {
|
for _, output := range references {
|
||||||
tempResults = append(tempResults, &transaction.Result{
|
tempResults = append(tempResults, &transaction.Result{
|
||||||
AssetID: output.AssetID,
|
AssetID: output.AssetID,
|
||||||
Amount: output.Amount,
|
Amount: output.Amount,
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
for _, output := range t.Outputs {
|
||||||
|
tempResults = append(tempResults, &transaction.Result{
|
||||||
|
AssetID: output.AssetID,
|
||||||
|
Amount: -output.Amount,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
for _, r := range tempResults {
|
||||||
|
if amount, ok := tempGroupResult[r.AssetID]; ok {
|
||||||
|
tempGroupResult[r.AssetID] = amount.Add(r.Amount)
|
||||||
|
} else {
|
||||||
|
tempGroupResult[r.AssetID] = r.Amount
|
||||||
}
|
}
|
||||||
for _, output := range t.Outputs {
|
|
||||||
tempResults = append(tempResults, &transaction.Result{
|
|
||||||
AssetID: output.AssetID,
|
|
||||||
Amount: -output.Amount,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
for _, r := range tempResults {
|
|
||||||
if amount, ok := tempGroupResult[r.AssetID]; ok {
|
|
||||||
tempGroupResult[r.AssetID] = amount.Add(r.Amount)
|
|
||||||
} else {
|
|
||||||
tempGroupResult[r.AssetID] = r.Amount
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
results = []*transaction.Result{} // this assignment is necessary. (Most of the time amount == 0 and results is the empty slice.)
|
|
||||||
for assetID, amount := range tempGroupResult {
|
|
||||||
if amount != util.Fixed8(0) {
|
|
||||||
results = append(results, &transaction.Result{
|
|
||||||
AssetID: assetID,
|
|
||||||
Amount: amount,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return results
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
results = []*transaction.Result{} // this assignment is necessary. (Most of the time amount == 0 and results is the empty slice.)
|
||||||
|
for assetID, amount := range tempGroupResult {
|
||||||
|
if amount != util.Fixed8(0) {
|
||||||
|
results = append(results, &transaction.Result{
|
||||||
|
AssetID: assetID,
|
||||||
|
Amount: amount,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return results
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetScriptHashesForVerifying returns all the ScriptHashes of a transaction which will be use
|
// GetScriptHashesForVerifying returns all the ScriptHashes of a transaction which will be use
|
||||||
|
|
Loading…
Reference in a new issue