update some comments

This commit is contained in:
Ethan Buchman 2018-06-04 13:59:28 -07:00
parent 3d33226e80
commit 97c5533c35
3 changed files with 7 additions and 9 deletions

View File

@ -69,16 +69,18 @@ func (evpool *EvidencePool) State() sm.State {
// Update loads the latest
func (evpool *EvidencePool) Update(block *types.Block, state sm.State) {
evpool.mtx.Lock()
defer evpool.mtx.Unlock()
// sanity check
if state.LastBlockHeight != block.Height {
panic(fmt.Sprintf("Failed EvidencePool.Update sanity check: got state.Height=%d with block.Height=%d", state.LastBlockHeight, block.Height))
}
evpool.state = state
// NOTE: shouldn't need the mutex
// update the state
evpool.mtx.Lock()
evpool.state = state
evpool.mtx.Unlock()
// remove evidence from pending and mark committed
evpool.MarkEvidenceAsCommitted(block.Evidence.Evidence)
}

View File

@ -17,10 +17,6 @@ Impl:
- First commit atomically in outqueue, pending, lookup.
- Once broadcast, remove from outqueue. No need to sync
- Once committed, atomically remove from pending and update lookup.
- TODO: If we crash after committed but before removing/updating,
we'll be stuck broadcasting evidence we never know we committed.
so either share the state db and atomically MarkCommitted
with ApplyBlock, or check all outqueue/pending on Start to see if its committed
Schema for indexing evidence (note you need both height and hash to find a piece of evidence):

View File

@ -92,7 +92,7 @@ func (blockExec *BlockExecutor) ApplyBlock(state State, blockID types.BlockID, b
return state, fmt.Errorf("Commit failed for application: %v", err)
}
// lock mempool, commit state, update mempoool
// lock mempool, commit app state, update mempoool
appHash, err := blockExec.Commit(block)
if err != nil {
return state, fmt.Errorf("Commit failed for application: %v", err)