Skip to content

Commit

Permalink
Merge pull request #6 from l3gacyb3ta/main
Browse files Browse the repository at this point in the history
fix: switch color to gchalk
  • Loading branch information
quackduck authored Sep 3, 2021
2 parents 3c93689 + 417038c commit 1970baf
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
Binary file added client/duckcoin
Binary file not shown.
Binary file added snode-src/duckcoin
Binary file not shown.
18 changes: 9 additions & 9 deletions snode-src/duckcoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"strings"
"time"

"github.com/fatih/color"
"github.com/jwalton/gchalk"
)

var (
Expand All @@ -34,7 +34,7 @@ var (
pubkeyFile = configDir + "/pubkey.pem"
privkeyFile = configDir + "/privkey.pem"
urlFile = configDir + "/url.txt"
// Difficulty is how many zeros are needed in front of a block hash to be considered a valid block. Thus, this controls how much work miners have to do.
// Difficulty is how many zeros are needed in front of a block hash to be consideBrightRed a valid block. Thus, this controls how much work miners have to do.
Difficulty = 5
helpMsg = `Duckcoin - quack money
Usage: duckcoin [<num of blocks>] [-t/--to <pubkey>] [-a/--amount <quacks>] [-m/--message <msg>]
Expand Down Expand Up @@ -149,7 +149,7 @@ func main() {
}
}
address = duckToAddress(pubkey)
fmt.Printf("Mining to this address: %s\n", color.HiBlueString(address))
fmt.Printf("Mining to this address: %s\n", gchalk.BrightBlue(address))

loadDifficultyAndURL()

Expand Down Expand Up @@ -192,7 +192,7 @@ func mine(numOfBlocks int, data string, receiver string, amount int) {
_ = r.Body.Close()
if currBlock != b {
if currBlock.Solver != address {
fmt.Println("Gotta restart, someone else got block", currBlock.Index)
fmt.Println(gchalk.RGB(255, 165, 0)("Gotta restart, someone else got block " + strconv.Itoa(int(currBlock.Index))))
b = currBlock
blockChan <- currBlock
}
Expand Down Expand Up @@ -271,7 +271,7 @@ Mine:
}
newBlock.Tx.Signature = signature
}
fmt.Println(color.HiYellowString(toJson(newBlock)))
fmt.Println(gchalk.BrightYellow(toJson(newBlock)))
j, jerr := json.Marshal(newBlock)
if jerr != nil {
fmt.Println(jerr)
Expand All @@ -287,7 +287,7 @@ Mine:
fmt.Println(ierr)
return
}
fmt.Println("Server returned", color.HiGreenString(string(resp))+"\n")
fmt.Println("Server returned", gchalk.BrightGreen(string(resp)))
r.Body.Close()
break Mine
}
Expand Down Expand Up @@ -370,8 +370,8 @@ func saveKeyPair(pubkey string, privkey string, pubfile string, privfile string)
return err
}

color.HiYellow("Your keys have been saved to " + pubfile + "(pubkey) and " + privfile + " (privkey)")
color.HiRed("Do not tell anyone what's inside " + privfile)
gchalk.BrightYellow("Your keys have been saved to " + pubfile + "(pubkey) and " + privfile + " (privkey)")
gchalk.BrightRed("Do not tell anyone what's inside " + privfile)
return nil
}

Expand All @@ -395,7 +395,7 @@ func loadKeyPair(pubfile string, privfile string) (pub string, priv string, err
return "", "", errors.New("could not decode PEM data from " + privfile)
}
privkey := base64.StdEncoding.EncodeToString(key.Bytes)
color.HiYellow("Loaded keys from " + pubfile + " and " + privfile)
gchalk.BrightYellow("Loaded keys from " + pubfile + " and " + privfile)
return pubkey, privkey, nil
}

Expand Down
2 changes: 1 addition & 1 deletion snode-src/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module duckcoin

go 1.16

require github.com/fatih/color v1.10.0
require github.com/jwalton/gchalk v1.1.0
18 changes: 9 additions & 9 deletions snode-src/go.sum
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg=
github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
github.com/jwalton/gchalk v1.1.0 h1:S1yNzYrPgdpP0wmWw75X6EK3SYLDJ/RsdbLUJ5PLhGU=
github.com/jwalton/gchalk v1.1.0/go.mod h1:kmvsubrIhnHSklat2ZWNj7zlLs3SS2wGNgsBVPtill4=
github.com/jwalton/go-supportscolor v1.0.0 h1:Do3OE2y/iUibg79+QhkRE6G2evYKEv2bwi6sGs8Nd7s=
github.com/jwalton/go-supportscolor v1.0.0/go.mod h1:hFVUAZV2cWg+WFFC4v8pT2X/S2qUUBYMioBD9AINXGs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43 h1:SgQ6LNaYJU0JIuEHv9+s6EbhSCwYeAf5Yvj6lpYlqAE=
golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d h1:SZxvLBoTP5yHO3Frd4z4vrF+DBX9vMVanchswa69toE=
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=

0 comments on commit 1970baf

Please sign in to comment.