aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-08-10 13:40:57 +0800
committerGitHub <noreply@github.com>2018-08-10 13:40:57 +0800
commitb88d8ddb0eaf48fac1fdf10dcd7db4dc896e6538 (patch)
tree9595ccf912234c24674138705d2cc2b463212905 /core
parent99d9591e5f0af54bf06f41cfd2658cfcc9ee6436 (diff)
downloaddexon-consensus-b88d8ddb0eaf48fac1fdf10dcd7db4dc896e6538.tar
dexon-consensus-b88d8ddb0eaf48fac1fdf10dcd7db4dc896e6538.tar.gz
dexon-consensus-b88d8ddb0eaf48fac1fdf10dcd7db4dc896e6538.tar.bz2
dexon-consensus-b88d8ddb0eaf48fac1fdf10dcd7db4dc896e6538.tar.lz
dexon-consensus-b88d8ddb0eaf48fac1fdf10dcd7db4dc896e6538.tar.xz
dexon-consensus-b88d8ddb0eaf48fac1fdf10dcd7db4dc896e6538.tar.zst
dexon-consensus-b88d8ddb0eaf48fac1fdf10dcd7db4dc896e6538.zip
core: Deliver only Hash to Application. (#43)
Diffstat (limited to 'core')
-rw-r--r--core/application.go3
-rw-r--r--core/consensus.go8
-rw-r--r--core/test/app.go9
3 files changed, 9 insertions, 11 deletions
diff --git a/core/application.go b/core/application.go
index 763954d..5bd325c 100644
--- a/core/application.go
+++ b/core/application.go
@@ -21,7 +21,6 @@ import (
"time"
"github.com/dexon-foundation/dexon-consensus-core/common"
- "github.com/dexon-foundation/dexon-consensus-core/core/types"
)
// Application describes the application interface that interacts with DEXON
@@ -31,7 +30,7 @@ type Application interface {
StronglyAcked(blockHash common.Hash)
// TotalOrderingDeliver is called when the total ordering algorithm deliver // a set of block.
- TotalOrderingDeliver(blocks []*types.Block, early bool)
+ TotalOrderingDeliver(blockHashes common.Hashes, early bool)
// DeliverBlock is called when a block is add to the compaction chain.
DeliverBlock(blockHash common.Hash, timestamp time.Time)
diff --git a/core/consensus.go b/core/consensus.go
index 6a97e9e..33f2f8b 100644
--- a/core/consensus.go
+++ b/core/consensus.go
@@ -22,6 +22,7 @@ import (
"time"
"github.com/dexon-foundation/dexon-consensus-core/blockdb"
+ "github.com/dexon-foundation/dexon-consensus-core/common"
"github.com/dexon-foundation/dexon-consensus-core/core/types"
)
@@ -101,8 +102,11 @@ func (con *Consensus) ProcessBlock(b *types.Block) (err error) {
}
}
// TODO(mission): handle membership events here.
- // TODO(mission): return block hash instead of whole block here.
- con.app.TotalOrderingDeliver(deliveredBlocks, earlyDelivered)
+ hashes := make(common.Hashes, len(deliveredBlocks))
+ for idx := range deliveredBlocks {
+ hashes[idx] = deliveredBlocks[idx].Hash
+ }
+ con.app.TotalOrderingDeliver(hashes, earlyDelivered)
// Perform timestamp generation.
deliveredBlocks, _, err = con.ctModule.processBlocks(
deliveredBlocks)
diff --git a/core/test/app.go b/core/test/app.go
index f596afb..55ba7c5 100644
--- a/core/test/app.go
+++ b/core/test/app.go
@@ -21,7 +21,6 @@ import (
"time"
"github.com/dexon-foundation/dexon-consensus-core/common"
- "github.com/dexon-foundation/dexon-consensus-core/core/types"
)
// App implements Application interface for testing purpose.
@@ -52,16 +51,12 @@ func (app *App) StronglyAcked(blockHash common.Hash) {
}
// TotalOrderingDeliver implements Application interface.
-func (app *App) TotalOrderingDeliver(blocks []*types.Block, early bool) {
- var hashes common.Hashes
- for _, b := range blocks {
- hashes = append(hashes, b.Hash)
- }
+func (app *App) TotalOrderingDeliver(blockHashes common.Hashes, early bool) {
app.TotalOrdered = append(app.TotalOrdered, &struct {
BlockHashes common.Hashes
Early bool
}{
- BlockHashes: hashes,
+ BlockHashes: blockHashes,
Early: early,
})
}