diff --git a/consensus/replay_file.go b/consensus/replay_file.go index 1fd4f415d..58f022274 100644 --- a/consensus/replay_file.go +++ b/consensus/replay_file.go @@ -29,6 +29,7 @@ const ( //-------------------------------------------------------- // replay messages interactively or all at once +// replay the wal file func RunReplayFile(config cfg.BaseConfig, csConfig *cfg.ConsensusConfig, console bool) { consensusState := newConsensusStateForReplay(config, csConfig) @@ -262,7 +263,7 @@ func (pb *playback) replayConsoleLoop() int { case "locked_block": fmt.Printf("%v %v\n", rs.LockedBlockParts.StringShort(), rs.LockedBlock.StringShort()) case "votes": - fmt.Println(rs.Votes.StringIndented(" ")) + fmt.Println(rs.Votes.StringIndented(" ")) default: fmt.Println("Unknown option", tokens[1]) diff --git a/consensus/types/state.go b/consensus/types/state.go index 255595e54..65c40781e 100644 --- a/consensus/types/state.go +++ b/consensus/types/state.go @@ -13,6 +13,7 @@ import ( // RoundStepType enumerates the state of the consensus state machine type RoundStepType uint8 // These must be numeric, ordered. +// RoundStepType const ( RoundStepNewHeight = RoundStepType(0x01) // Wait til CommitTime + timeoutCommit RoundStepNewRound = RoundStepType(0x02) // Setup new round and go to RoundStepPropose @@ -80,12 +81,12 @@ type RoundState struct { func (rs *RoundState) RoundStateEvent() types.EventDataRoundState { // XXX: copy the RoundState // if we want to avoid this, we may need synchronous events after all - rs_ := *rs + rsCopy := *rs edrs := types.EventDataRoundState{ Height: rs.Height, Round: rs.Round, Step: rs.Step.String(), - RoundState: &rs_, + RoundState: &rsCopy, } return edrs } @@ -115,16 +116,16 @@ func (rs *RoundState) StringIndented(indent string) string { indent, rs.Height, rs.Round, rs.Step, indent, rs.StartTime, indent, rs.CommitTime, - indent, rs.Validators.StringIndented(indent+" "), + indent, rs.Validators.StringIndented(indent+" "), indent, rs.Proposal, indent, rs.ProposalBlockParts.StringShort(), rs.ProposalBlock.StringShort(), indent, rs.LockedRound, indent, rs.LockedBlockParts.StringShort(), rs.LockedBlock.StringShort(), indent, rs.ValidRound, indent, rs.ValidBlockParts.StringShort(), rs.ValidBlock.StringShort(), - indent, rs.Votes.StringIndented(indent+" "), + indent, rs.Votes.StringIndented(indent+" "), indent, rs.LastCommit.StringShort(), - indent, rs.LastValidators.StringIndented(indent+" "), + indent, rs.LastValidators.StringIndented(indent+" "), indent) } diff --git a/types/genesis.go b/types/genesis.go index faf511196..aee8e0767 100644 --- a/types/genesis.go +++ b/types/genesis.go @@ -41,7 +41,7 @@ func (genDoc *GenesisDoc) AppState() json.RawMessage { // SaveAs is a utility method for saving GenensisDoc as a JSON file. func (genDoc *GenesisDoc) SaveAs(file string) error { - genDocBytes, err := cdc.MarshalJSON(genDoc) + genDocBytes, err := cdc.MarshalJSONIndent(genDoc, "", " ") if err != nil { return err } diff --git a/types/priv_validator/priv_validator.go b/types/priv_validator/priv_validator.go index baff28f64..2bb5ef323 100644 --- a/types/priv_validator/priv_validator.go +++ b/types/priv_validator/priv_validator.go @@ -120,7 +120,7 @@ func (pv *FilePV) save() { if outFile == "" { panic("Cannot save PrivValidator: filePath not set") } - jsonBytes, err := cdc.MarshalJSON(pv) + jsonBytes, err := cdc.MarshalJSONIndent(pv, "", " ") if err != nil { panic(err) } diff --git a/types/validator_set.go b/types/validator_set.go index fa6a2ad9c..28d954f35 100644 --- a/types/validator_set.go +++ b/types/validator_set.go @@ -69,6 +69,7 @@ func (valSet *ValidatorSet) IncrementAccum(times int) { } } +// Copy each validator into a new ValidatorSet func (valSet *ValidatorSet) Copy() *ValidatorSet { validators := make([]*Validator, len(valSet.Validators)) for i, val := range valSet.Validators { @@ -368,6 +369,7 @@ func (valSet *ValidatorSet) String() string { return valSet.StringIndented("") } +// String func (valSet *ValidatorSet) StringIndented(indent string) string { if valSet == nil { return "nil-ValidatorSet" @@ -384,7 +386,7 @@ func (valSet *ValidatorSet) StringIndented(indent string) string { %s}`, indent, valSet.GetProposer().String(), indent, - indent, strings.Join(valStrings, "\n"+indent+" "), + indent, strings.Join(valStrings, "\n"+indent+" "), indent) } @@ -392,6 +394,7 @@ func (valSet *ValidatorSet) StringIndented(indent string) string { //------------------------------------- // Implements sort for sorting validators by address. +// Sort validators by address type ValidatorsByAddress []*Validator func (vs ValidatorsByAddress) Len() int {