Browse Source

update some comments

pull/1628/head
Ethan Buchman 6 years ago
parent
commit
97c5533c35
3 changed files with 6 additions and 8 deletions
  1. +5
    -3
      evidence/pool.go
  2. +0
    -4
      evidence/store.go
  3. +1
    -1
      state/execution.go

+ 5
- 3
evidence/pool.go 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))
}
// update the state
evpool.mtx.Lock()
evpool.state = state
evpool.mtx.Unlock()
// NOTE: shouldn't need the mutex
// remove evidence from pending and mark committed
evpool.MarkEvidenceAsCommitted(block.Evidence.Evidence)
}


+ 0
- 4
evidence/store.go 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):


+ 1
- 1
state/execution.go 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)


Loading…
Cancel
Save