Skip to content

Commit cf9367a

Browse files
committed
feat: pass gossiped Commit between block manager and p2p layer
1 parent 09eb681 commit cf9367a

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

block/manager.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ type Manager struct {
6161

6262
CommitInCh chan *types.Commit
6363
CommitOutCh chan *types.Commit
64+
lastCommit *types.Commit
6465

6566
syncTarget uint64
6667
blockInCh chan newBlockEvent
@@ -204,6 +205,9 @@ func (m *Manager) SyncLoop(ctx context.Context) {
204205
atomic.StoreUint64(&m.syncTarget, newHeight)
205206
m.retrieveCond.Signal()
206207
}
208+
case commit := <-m.CommitInCh:
209+
// TODO(tzdybal): check if it's from right aggregator
210+
m.lastCommit = commit
207211
case blockEvent := <-m.blockInCh:
208212
block := blockEvent.block
209213
daHeight := blockEvent.daHeight
@@ -438,6 +442,7 @@ func (m *Manager) publishBlock(ctx context.Context) error {
438442
m.store.SetHeight(block.Header.Height)
439443

440444
m.publishHeader(block)
445+
m.publishCommit(lastCommit)
441446

442447
return nil
443448
}
@@ -476,10 +481,16 @@ func (m *Manager) exponentialBackoff(backoff time.Duration) time.Duration {
476481
return backoff
477482
}
478483

484+
// TODO(tzdybal): consider inlining
479485
func (m *Manager) publishHeader(block *types.Block) {
480486
m.HeaderOutCh <- &block.Header
481487
}
482488

489+
// TODO(tzdybal): consider inlining
490+
func (m *Manager) publishCommit(commit *types.Commit) {
491+
m.CommitOutCh <- commit
492+
}
493+
483494
func updateState(s *types.State, res *abci.ResponseInitChain) {
484495
// If the app did not return an app hash, we keep the one set from the genesis doc in
485496
// the state. We don't set appHash since we don't want the genesis doc app hash

0 commit comments

Comments
 (0)