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