|
|
@ -46,6 +46,31 @@ func (prs PeerRoundState) String() string { |
|
|
|
return prs.StringIndented("") |
|
|
|
} |
|
|
|
|
|
|
|
// Copy provides a deep copy operation. Because many of the fields in
|
|
|
|
// the PeerRound struct are pointers, we need an explicit deep copy
|
|
|
|
// operation to avoid a non-obvious shared data situation.
|
|
|
|
func (prs PeerRoundState) Copy() PeerRoundState { |
|
|
|
// this works because it's not a pointer receiver so it's
|
|
|
|
// already, effectively a copy.
|
|
|
|
|
|
|
|
headerHash := prs.ProposalBlockPartSetHeader.Hash.Bytes() |
|
|
|
|
|
|
|
hashCopy := make([]byte, len(headerHash)) |
|
|
|
copy(hashCopy, headerHash) |
|
|
|
prs.ProposalBlockPartSetHeader = types.PartSetHeader{ |
|
|
|
Total: prs.ProposalBlockPartSetHeader.Total, |
|
|
|
Hash: hashCopy, |
|
|
|
} |
|
|
|
prs.ProposalBlockParts = prs.ProposalBlockParts.Copy() |
|
|
|
prs.ProposalPOL = prs.ProposalPOL.Copy() |
|
|
|
prs.Prevotes = prs.Prevotes.Copy() |
|
|
|
prs.Precommits = prs.Precommits.Copy() |
|
|
|
prs.LastCommit = prs.LastCommit.Copy() |
|
|
|
prs.CatchupCommit = prs.CatchupCommit.Copy() |
|
|
|
|
|
|
|
return prs |
|
|
|
} |
|
|
|
|
|
|
|
// StringIndented returns a string representation of the PeerRoundState
|
|
|
|
func (prs PeerRoundState) StringIndented(indent string) string { |
|
|
|
return fmt.Sprintf(`PeerRoundState{ |
|
|
|