Statediffing #5
@ -54,7 +54,6 @@ func findIntersection(a, b []string) []string {
|
|||||||
if iOfA >= lenA {
|
if iOfA >= lenA {
|
||||||
return updates
|
return updates
|
||||||
}
|
}
|
||||||
break
|
|
||||||
// a[iOfA] == b[iOfB]
|
// a[iOfA] == b[iOfB]
|
||||||
case 0:
|
case 0:
|
||||||
updates = append(updates, a[iOfA])
|
updates = append(updates, a[iOfA])
|
||||||
@ -63,14 +62,12 @@ func findIntersection(a, b []string) []string {
|
|||||||
if iOfA >= lenA || iOfB >= lenB {
|
if iOfA >= lenA || iOfB >= lenB {
|
||||||
return updates
|
return updates
|
||||||
}
|
}
|
||||||
break
|
|
||||||
// a[iOfA] > b[iOfB]
|
// a[iOfA] > b[iOfB]
|
||||||
case 1:
|
case 1:
|
||||||
iOfB++
|
iOfB++
|
||||||
if iOfB >= lenB {
|
if iOfB >= lenB {
|
||||||
return updates
|
return updates
|
||||||
}
|
}
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,9 +47,7 @@ func (p *publisher) publishStateDiffToCSV(sd builder.StateDiff) (string, error)
|
|||||||
|
|
||||||
var data [][]string
|
var data [][]string
|
||||||
data = append(data, Headers)
|
data = append(data, Headers)
|
||||||
for _, row := range accumulateAccountRows(sd) {
|
data = append(data, accumulateAccountRows(sd)...)
|
||||||
data = append(data, row)
|
|
||||||
}
|
|
||||||
for _, value := range data {
|
for _, value := range data {
|
||||||
err := writer.Write(value)
|
err := writer.Write(value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -65,25 +63,19 @@ func accumulateAccountRows(sd builder.StateDiff) [][]string {
|
|||||||
for accountAddr, accountDiff := range sd.CreatedAccounts {
|
for accountAddr, accountDiff := range sd.CreatedAccounts {
|
||||||
formattedAccountData := formatAccountData(accountAddr, accountDiff, sd, createdAccountAction)
|
formattedAccountData := formatAccountData(accountAddr, accountDiff, sd, createdAccountAction)
|
||||||
|
|
||||||
for _, accountData := range formattedAccountData {
|
accountRows = append(accountRows, formattedAccountData...)
|
||||||
accountRows = append(accountRows, accountData)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for accountAddr, accountDiff := range sd.UpdatedAccounts {
|
for accountAddr, accountDiff := range sd.UpdatedAccounts {
|
||||||
formattedAccountData := formatAccountData(accountAddr, accountDiff, sd, updatedAccountAction)
|
formattedAccountData := formatAccountData(accountAddr, accountDiff, sd, updatedAccountAction)
|
||||||
|
|
||||||
for _, accountData := range formattedAccountData {
|
accountRows = append(accountRows, formattedAccountData...)
|
||||||
accountRows = append(accountRows, accountData)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for accountAddr, accountDiff := range sd.DeletedAccounts {
|
for accountAddr, accountDiff := range sd.DeletedAccounts {
|
||||||
formattedAccountData := formatAccountData(accountAddr, accountDiff, sd, deletedAccountAction)
|
formattedAccountData := formatAccountData(accountAddr, accountDiff, sd, deletedAccountAction)
|
||||||
|
|
||||||
for _, accountData := range formattedAccountData {
|
accountRows = append(accountRows, formattedAccountData...)
|
||||||
accountRows = append(accountRows, accountData)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return accountRows
|
return accountRows
|
||||||
|
Loading…
Reference in New Issue
Block a user