diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/consensus.go | 2 | ||||
-rw-r--r-- | core/interfaces.go | 3 | ||||
-rw-r--r-- | core/lattice_test.go | 2 | ||||
-rw-r--r-- | core/nonblocking.go | 16 | ||||
-rw-r--r-- | core/nonblocking_test.go | 13 | ||||
-rw-r--r-- | core/test/app.go | 3 | ||||
-rw-r--r-- | core/test/app_test.go | 2 | ||||
-rw-r--r-- | core/test/stopper_test.go | 2 |
8 files changed, 24 insertions, 19 deletions
diff --git a/core/consensus.go b/core/consensus.go index cec3c4f..0371e60 100644 --- a/core/consensus.go +++ b/core/consensus.go @@ -929,7 +929,7 @@ func (con *Consensus) preProcessBlock(b *types.Block) (err error) { func (con *Consensus) deliverBlock(b *types.Block) { // TODO(mission): clone types.FinalizationResult con.logger.Debug("Calling Application.BlockDelivered", "block", b) - con.app.BlockDelivered(b.Hash, b.Finalization) + con.app.BlockDelivered(b.Hash, b.Position, b.Finalization) if b.Position.Round+2 == con.roundToNotify { // Only the first block delivered of that round would // trigger this noitification. diff --git a/core/interfaces.go b/core/interfaces.go index 75a2fdf..3a9c075 100644 --- a/core/interfaces.go +++ b/core/interfaces.go @@ -42,7 +42,8 @@ type Application interface { BlockConfirmed(block types.Block) // BlockDelivered is called when a block is add to the compaction chain. - BlockDelivered(blockHash common.Hash, result types.FinalizationResult) + BlockDelivered(blockHash common.Hash, + blockPosition types.Position, result types.FinalizationResult) } // Debug describes the application interface that requires diff --git a/core/lattice_test.go b/core/lattice_test.go index ca3cfbb..b469565 100644 --- a/core/lattice_test.go +++ b/core/lattice_test.go @@ -80,7 +80,7 @@ func (mgr *testLatticeMgr) processBlock(b *types.Block) (err error) { if err = mgr.db.Update(*b); err != nil { return } - mgr.app.BlockDelivered(b.Hash, b.Finalization) + mgr.app.BlockDelivered(b.Hash, b.Position, b.Finalization) } if err = mgr.lattice.PurgeBlocks(delivered); err != nil { return diff --git a/core/nonblocking.go b/core/nonblocking.go index fafbd10..a73331f 100644 --- a/core/nonblocking.go +++ b/core/nonblocking.go @@ -39,8 +39,9 @@ type totalOrderingDeliveredEvent struct { } type blockDeliveredEvent struct { - blockHash common.Hash - result *types.FinalizationResult + blockHash common.Hash + blockPosition types.Position + result *types.FinalizationResult } // nonBlocking implements these interfaces and is a decorator for @@ -99,7 +100,7 @@ func (nb *nonBlocking) run() { case totalOrderingDeliveredEvent: nb.debug.TotalOrderingDelivered(e.blockHashes, e.mode) case blockDeliveredEvent: - nb.app.BlockDelivered(e.blockHash, *e.result) + nb.app.BlockDelivered(e.blockHash, e.blockPosition, *e.result) default: fmt.Printf("Unknown event %v.", e) } @@ -155,10 +156,11 @@ func (nb *nonBlocking) TotalOrderingDelivered( } // BlockDelivered is called when a block is add to the compaction chain. -func (nb *nonBlocking) BlockDelivered( - blockHash common.Hash, result types.FinalizationResult) { +func (nb *nonBlocking) BlockDelivered(blockHash common.Hash, + blockPosition types.Position, result types.FinalizationResult) { nb.addEvent(blockDeliveredEvent{ - blockHash: blockHash, - result: &result, + blockHash: blockHash, + blockPosition: blockPosition, + result: &result, }) } diff --git a/core/nonblocking_test.go b/core/nonblocking_test.go index 3a4ec6c..d486ca2 100644 --- a/core/nonblocking_test.go +++ b/core/nonblocking_test.go @@ -75,8 +75,8 @@ func (app *slowApp) TotalOrderingDelivered(blockHashes common.Hashes, mode uint3 } } -func (app *slowApp) BlockDelivered( - blockHash common.Hash, _ types.FinalizationResult) { +func (app *slowApp) BlockDelivered(blockHash common.Hash, + blockPosition types.Position, _ types.FinalizationResult) { time.Sleep(app.sleep) app.blockDelivered[blockHash] = struct{}{} } @@ -111,8 +111,8 @@ func (app *noDebugApp) BlockConfirmed(block types.Block) { app.blockConfirmed[block.Hash] = struct{}{} } -func (app *noDebugApp) BlockDelivered( - blockHash common.Hash, _ types.FinalizationResult) { +func (app *noDebugApp) BlockDelivered(blockHash common.Hash, + blockPosition types.Position, _ types.FinalizationResult) { app.blockDelivered[blockHash] = struct{}{} } @@ -138,7 +138,8 @@ func (s *NonBlockingTestSuite) TestNonBlocking() { Witness: types.Witness{}, }) nbModule.StronglyAcked(hash) - nbModule.BlockDelivered(hash, types.FinalizationResult{}) + nbModule.BlockDelivered( + hash, types.Position{}, types.FinalizationResult{}) } nbModule.TotalOrderingDelivered(hashes, TotalOrderingModeEarly) @@ -161,7 +162,7 @@ func (s *NonBlockingTestSuite) TestNoDebug() { // Test BlockConfirmed. nbModule.BlockConfirmed(types.Block{Hash: hash}) // Test BlockDelivered - nbModule.BlockDelivered(hash, types.FinalizationResult{}) + nbModule.BlockDelivered(hash, types.Position{}, types.FinalizationResult{}) nbModule.wait() s.Contains(app.blockConfirmed, hash) s.Contains(app.blockDelivered, hash) diff --git a/core/test/app.go b/core/test/app.go index 228edb4..7477329 100644 --- a/core/test/app.go +++ b/core/test/app.go @@ -162,7 +162,7 @@ func (app *App) TotalOrderingDelivered(blockHashes common.Hashes, mode uint32) { // BlockDelivered implements Application interface. func (app *App) BlockDelivered( - blockHash common.Hash, result types.FinalizationResult) { + blockHash common.Hash, _ types.Position, result types.FinalizationResult) { func() { app.deliveredLock.Lock() defer app.deliveredLock.Unlock() @@ -220,6 +220,7 @@ func (app *App) Compare(other *App) error { // Verify checks the integrity of date received by this App instance. func (app *App) Verify() error { + // TODO(mission): verify blocks' position when delivered. app.deliveredLock.RLock() defer app.deliveredLock.RUnlock() diff --git a/core/test/app_test.go b/core/test/app_test.go index eb14039..4a7c4b9 100644 --- a/core/test/app_test.go +++ b/core/test/app_test.go @@ -82,7 +82,7 @@ func (s *AppTestSuite) deliverBlockWithTimeFromSequenceLength( func (s *AppTestSuite) deliverBlock( app *App, hash common.Hash, timestamp time.Time, height uint64) { - app.BlockDelivered(hash, types.FinalizationResult{ + app.BlockDelivered(hash, types.Position{}, types.FinalizationResult{ Timestamp: timestamp, Height: height, }) diff --git a/core/test/stopper_test.go b/core/test/stopper_test.go index 3ba7db6..d823f59 100644 --- a/core/test/stopper_test.go +++ b/core/test/stopper_test.go @@ -44,7 +44,7 @@ func (s *StopperTestSuite) deliver( } app.TotalOrderingDelivered(hashes, core.TotalOrderingModeNormal) for _, h := range hashes { - app.BlockDelivered(h, types.FinalizationResult{ + app.BlockDelivered(h, types.Position{}, types.FinalizationResult{ Timestamp: time.Time{}, }) } |