Skip to content
Snippets Groups Projects
Commit 879bc601 authored by Miguel Montes's avatar Miguel Montes
Browse files

Corrección de bugs en -output-format

parent 97fb3234
No related branches found
No related tags found
No related merge requests found
......@@ -190,15 +190,19 @@ func weiTo(wei *big.Float, unit string) (value *big.Float, ok bool) {
func sealers() {
var (
blockNumber int64
lastBlock bool
timestamp bool
difficulty bool
balance bool
header bool
format string
formatStr string
unit string
blockNumber int64
lastBlock bool
timestamp bool
difficulty bool
balance bool
header bool
format string
formatStr string
unit string
list []string
lastBlockLen int64
timestampLen int64
balanceLen int64
)
description = "Presenta la lista de selladores. Opcionalmente presenta información sobre los selladores."
setFlags()
......@@ -236,23 +240,25 @@ func sealers() {
util.PrintJson(sealers)
return
}
var (
list []string
lastBlockLen int64
timestampLen int64
balanceLen int64
)
if len(format) > 0 {
format = parseFormatString(format)
timestampLen = int64(len(format))
} else {
timestampLen = 10
}
for sealer := range sealers {
list = append(list, sealer)
}
if formatStr != "" {
sort.Strings(list)
formatStr = strings.Replace(formatStr, "{sealer}", "%[1]v", 1)
formatStr = strings.Replace(formatStr, "{last-block}", "%[3]v", 1)
formatStr = strings.Replace(formatStr, "{timestamp}", "%[5]v", 1)
formatStr = strings.Replace(formatStr, "{difficulty}", "%[6]v", 1)
formatStr = strings.Replace(formatStr, "{balance}", "%[8]v", 1)
timestamp = false
formatStr = strings.Replace(formatStr, "%", "%%", -1)
formatStr = strings.Replace(formatStr, "{sealer}", "%[1]v", -1)
formatStr = strings.Replace(formatStr, "{last-block}", "%[3]v", -1)
formatStr = strings.Replace(formatStr, "{timestamp}", "%[5]v", -1)
formatStr = strings.Replace(formatStr, "{difficulty}", "%[6]v", -1)
formatStr = strings.Replace(formatStr, "{balance}", "%[8]v", -1)
} else {
switch {
case lastBlock:
......@@ -271,12 +277,6 @@ func sealers() {
}
if timestamp {
formatStr += " %[4]*[5]v"
if len(format) > 0 {
format = parseFormatString(format)
timestampLen = int64(len(format))
} else {
timestampLen = 10
}
}
if difficulty {
formatStr += " %2[6]v"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment