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) { ...@@ -190,15 +190,19 @@ func weiTo(wei *big.Float, unit string) (value *big.Float, ok bool) {
func sealers() { func sealers() {
var ( var (
blockNumber int64 blockNumber int64
lastBlock bool lastBlock bool
timestamp bool timestamp bool
difficulty bool difficulty bool
balance bool balance bool
header bool header bool
format string format string
formatStr string formatStr string
unit string unit string
list []string
lastBlockLen int64
timestampLen int64
balanceLen int64
) )
description = "Presenta la lista de selladores. Opcionalmente presenta información sobre los selladores." description = "Presenta la lista de selladores. Opcionalmente presenta información sobre los selladores."
setFlags() setFlags()
...@@ -236,23 +240,25 @@ func sealers() { ...@@ -236,23 +240,25 @@ func sealers() {
util.PrintJson(sealers) util.PrintJson(sealers)
return return
} }
var (
list []string if len(format) > 0 {
lastBlockLen int64 format = parseFormatString(format)
timestampLen int64 timestampLen = int64(len(format))
balanceLen int64 } else {
) timestampLen = 10
}
for sealer := range sealers { for sealer := range sealers {
list = append(list, sealer) list = append(list, sealer)
} }
if formatStr != "" { if formatStr != "" {
sort.Strings(list) sort.Strings(list)
formatStr = strings.Replace(formatStr, "{sealer}", "%[1]v", 1) formatStr = strings.Replace(formatStr, "%", "%%", -1)
formatStr = strings.Replace(formatStr, "{last-block}", "%[3]v", 1) formatStr = strings.Replace(formatStr, "{sealer}", "%[1]v", -1)
formatStr = strings.Replace(formatStr, "{timestamp}", "%[5]v", 1) formatStr = strings.Replace(formatStr, "{last-block}", "%[3]v", -1)
formatStr = strings.Replace(formatStr, "{difficulty}", "%[6]v", 1) formatStr = strings.Replace(formatStr, "{timestamp}", "%[5]v", -1)
formatStr = strings.Replace(formatStr, "{balance}", "%[8]v", 1) formatStr = strings.Replace(formatStr, "{difficulty}", "%[6]v", -1)
timestamp = false formatStr = strings.Replace(formatStr, "{balance}", "%[8]v", -1)
} else { } else {
switch { switch {
case lastBlock: case lastBlock:
...@@ -271,12 +277,6 @@ func sealers() { ...@@ -271,12 +277,6 @@ func sealers() {
} }
if timestamp { if timestamp {
formatStr += " %[4]*[5]v" formatStr += " %[4]*[5]v"
if len(format) > 0 {
format = parseFormatString(format)
timestampLen = int64(len(format))
} else {
timestampLen = 10
}
} }
if difficulty { if difficulty {
formatStr += " %2[6]v" 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