Skip to content

Commit

Permalink
chore: changing config value on key to string, for easier reading whe…
Browse files Browse the repository at this point in the history
…n debugging// looking for it.

not an issue for usage, only a improvement.
  • Loading branch information
afa7789 authored and revitteth committed Oct 18, 2024
1 parent d0bb620 commit c54a3ae
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions cmd/acl/mode/mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

var (
mode string // Mode of the ACL
logCountOutput int // Output for log count
logCountOutput string // Output for log count
)

var Command = cli.Command{
Expand All @@ -25,7 +25,7 @@ var Command = cli.Command{
Usage: "Mode of the ACL (allowlist, blocklist or disabled)",
Destination: &mode,
},
&cli.IntFlag{
&cli.StringFlag{
Name: "log_count",
Usage: "Number of transactions at startup to log",
Destination: &logCountOutput,
Expand Down
20 changes: 15 additions & 5 deletions zk/txpool/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/binary"
"encoding/hex"
"fmt"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -363,7 +364,12 @@ func LastPolicyTransactions(ctx context.Context, aclDB kv.RwDB) ([]PolicyTransac
if len(value) == 0 {
return nil
}
logOutputcount = int(binary.BigEndian.Uint64(value))

logOutputcountStr := string(value)
logOutputcount, err = strconv.Atoi(logOutputcountStr)
if err != nil {
return err
}
return nil
})
if err != nil {
Expand Down Expand Up @@ -629,11 +635,15 @@ func SetMode(ctx context.Context, aclDB kv.RwDB, mode string) error {
}

// SetLogCount sets the mode of the ACL
func SetLogCount(ctx context.Context, aclDB kv.RwDB, logCount int) error {
func SetLogCount(ctx context.Context, aclDB kv.RwDB, logCount string) error {

_, err := strconv.Atoi(logCount)
if err != nil {
return fmt.Errorf("invalid log count, nan: %s", logCount)
}

return aclDB.Update(ctx, func(tx kv.RwTx) error {
logCountBytes := make([]byte, 8)
binary.BigEndian.PutUint64(logCountBytes, uint64(logCount))
return tx.Put(Config, []byte(logCountPolicyTransactions), logCountBytes)
return tx.Put(Config, []byte(logCountPolicyTransactions), []byte(logCount))
})
}

Expand Down

0 comments on commit c54a3ae

Please sign in to comment.