hotstuff
hotstuff copied to clipboard
refactor: Blockchain to use idiomatic Go
This method:
func (chain *Blockchain) LocalGet(hash hotstuff.Hash) (*hotstuff.Block, bool) {
Since this already returns a pointer to a block, there is no need to also return a bool. We can simply replace the ok check with a nil check. Thus, the implementation simply becomes:
func (chain *Blockchain) LocalGet(hash hotstuff.Hash) *hotstuff.Block {
chain.mut.Lock()
defer chain.mut.Unlock()
return chain.blocks[hash]
}
Similar adjustments should be made for this method:
func (chain *Blockchain) Get(hash hotstuff.Hash) (block *hotstuff.Block, ok bool) {