forked from envadiv/mainnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
audit.go
46 lines (39 loc) · 911 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
package main
import (
"fmt"
"io"
"sort"
"time"
)
func SortAccounts(accMap map[string]Account) []Account {
var addrs []string
for addr := range accMap {
addrs = append(addrs, addr)
}
sort.Strings(addrs)
res := make([]Account, 0, len(accMap))
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.TotalPassage, 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.Passage, timeStr)
if err != nil {
panic(err)
}
}
}
}