forked from regen-network/mainnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
audit.go
49 lines (43 loc) · 1002 Bytes
/
audit.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"fmt"
"io"
"sort"
"time"
)
func SortAccounts(accounts []Account) []Account {
var addrs []string
accMap := make(map[string]Account)
// sort
for _, acc := range accounts {
addr := acc.Address.String()
addrs = append(addrs, addr)
accMap[addr] = acc
}
sort.Strings(addrs)
res := make([]Account, 0, len(accounts))
for _, addr := range addrs {
res = append(res, accMap[addr])
}
return res
}
func PrintAccountAudit(accounts []Account, genesisTime time.Time, writer io.Writer) {
for _, acc := range accounts {
_, err := fmt.Fprintf(writer, "%s\t%s\t%d\n", acc.Address, acc.TotalRegen, len(acc.Distributions))
if err != nil {
panic(err)
}
for _, dist := range acc.Distributions {
var timeStr string
if dist.Time.Equal(genesisTime) {
timeStr = "MAINNET"
} else {
timeStr = dist.Time.Format("2006-01-02 15:04:05")
}
_, err = fmt.Fprintf(writer, "\t%s\t%s\n", dist.Regen, timeStr)
if err != nil {
panic(err)
}
}
}
}