From bcfe33f15c88ad96b52749ee5d1bf7aa7de326c5 Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Tue, 14 Apr 2015 01:14:55 -0700 Subject: [PATCH] rename debora -> barak --- Makefile | 4 ++-- cmd/{debora => barak}/auth.go | 2 +- cmd/{debora => barak}/log.go | 0 cmd/{debora => barak}/main.go | 40 ++++++++++++++++++----------------- cmd/{debora => barak}/seed | 0 5 files changed, 24 insertions(+), 22 deletions(-) rename cmd/{debora => barak}/auth.go (96%) rename cmd/{debora => barak}/log.go (100%) rename cmd/{debora => barak}/main.go (90%) rename cmd/{debora => barak}/seed (100%) diff --git a/Makefile b/Makefile index 6011e5b97..3743c7289 100644 --- a/Makefile +++ b/Makefile @@ -4,11 +4,11 @@ all: build build: get_deps go build -o build/tendermint github.com/tendermint/tendermint/cmd/tendermint - go build -o build/debora github.com/tendermint/tendermint/cmd/debora + go build -o build/barak github.com/tendermint/tendermint/cmd/barak build_race: get_deps go build -race -o build/tendermint github.com/tendermint/tendermint/cmd/tendermint - go build -race -o build/debora github.com/tendermint/tendermint/cmd/debora + go build -race -o build/barak github.com/tendermint/tendermint/cmd/barak test: build go test github.com/tendermint/tendermint/... diff --git a/cmd/debora/auth.go b/cmd/barak/auth.go similarity index 96% rename from cmd/debora/auth.go rename to cmd/barak/auth.go index 83a81121a..c8935c376 100644 --- a/cmd/debora/auth.go +++ b/cmd/barak/auth.go @@ -25,7 +25,7 @@ func validate(signBytes []byte, validators []Validator, signatures []acm.Signatu NOTE: Not used, just here in case we want it later. func ValidateHandler(handler http.Handler, validators []Validator) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - sigStrs := r.Header[http.CanonicalHeaderKey("debora-signatures")] + sigStrs := r.Header[http.CanonicalHeaderKey("signatures")] log.Debug("Woot", "sigstrs", sigStrs, "len", len(sigStrs)) // from https://medium.com/@xoen/golang-read-from-an-io-readwriter-without-loosing-its-content-2c6911805361 // Read the content diff --git a/cmd/debora/log.go b/cmd/barak/log.go similarity index 100% rename from cmd/debora/log.go rename to cmd/barak/log.go diff --git a/cmd/debora/main.go b/cmd/barak/main.go similarity index 90% rename from cmd/debora/main.go rename to cmd/barak/main.go index ca638eca4..d789c1705 100644 --- a/cmd/debora/main.go +++ b/cmd/barak/main.go @@ -1,5 +1,7 @@ package main +// A note on the origin of the name. +// http://en.wikipedia.org/wiki/Barak // TODO: Nonrepudiable command log import ( @@ -31,7 +33,7 @@ type Options struct { } // Global instance -var debora = struct { +var barak = struct { mtx sync.Mutex processes map[string]*pcm.Process validators []Validator @@ -50,12 +52,12 @@ func main() { if err != nil { panic(Fmt("Error parsing input: %v", err)) } - debora.nonce = options.StartNonce - debora.validators = options.Validators + barak.nonce = options.StartNonce + barak.validators = options.Validators // Debug. fmt.Printf("Options: %v\n", options) - fmt.Printf("Debora: %v\n", debora) + fmt.Printf("Barak: %v\n", barak) // Start rpc server. mux := http.NewServeMux() @@ -65,7 +67,7 @@ func main() { rpc.StartHTTPServer(options.ListenAddress, mux) TrapSignal(func() { - fmt.Println("Debora shutting down") + fmt.Println("Barak shutting down") }) } @@ -105,7 +107,7 @@ func parseValidateCommand(authCommand AuthCommand) (Command, error) { commandJSONStr := authCommand.CommandJSONStr signatures := authCommand.Signatures // Validate commandJSONStr - if !validate([]byte(commandJSONStr), debora.validators, signatures) { + if !validate([]byte(commandJSONStr), barak.validators, signatures) { fmt.Printf("Failed validation attempt") return nil, errors.New("Validation error") } @@ -117,10 +119,10 @@ func parseValidateCommand(authCommand AuthCommand) (Command, error) { return nil, errors.New("Command parse error") } // Prevent replays - if debora.nonce+1 != command.Nonce { + if barak.nonce+1 != command.Nonce { return nil, errors.New("Replay error") } else { - debora.nonce += 1 + barak.nonce += 1 } return command.Command, nil } @@ -171,19 +173,19 @@ type ResponseRunProcess struct { } func RunProcess(wait bool, label string, execPath string, args []string, input string) (*ResponseRunProcess, error) { - debora.mtx.Lock() + barak.mtx.Lock() // First, see if there already is a process labeled 'label' - existing := debora.processes[label] + existing := barak.processes[label] if existing != nil { - debora.mtx.Unlock() + barak.mtx.Unlock() return nil, Errorf("Process already exists: %v", label) } // Otherwise, create one. proc := pcm.Create(pcm.ProcessModeDaemon, label, execPath, args, input) - debora.processes[label] = proc - debora.mtx.Unlock() + barak.processes[label] = proc + barak.mtx.Unlock() if wait { exitErr := pcm.Wait(proc) @@ -206,9 +208,9 @@ type ResponseStopProcess struct { } func StopProcess(label string, kill bool) (*ResponseStopProcess, error) { - debora.mtx.Lock() - proc := debora.processes[label] - debora.mtx.Unlock() + barak.mtx.Lock() + proc := barak.processes[label] + barak.mtx.Unlock() if proc == nil { return nil, Errorf("Process does not exist: %v", label) @@ -230,11 +232,11 @@ type ResponseListProcesses struct { func ListProcesses() (*ResponseListProcesses, error) { var procs = []*pcm.Process{} - debora.mtx.Lock() - for _, proc := range debora.processes { + barak.mtx.Lock() + for _, proc := range barak.processes { procs = append(procs, proc) } - debora.mtx.Unlock() + barak.mtx.Unlock() return &ResponseListProcesses{ Processes: procs, diff --git a/cmd/debora/seed b/cmd/barak/seed similarity index 100% rename from cmd/debora/seed rename to cmd/barak/seed