diff options
author | Mission Liao <mission.liao@dexon.org> | 2018-09-25 14:10:16 +0800 |
---|---|---|
committer | Wei-Ning Huang <aitjcize@gmail.com> | 2018-09-25 14:10:16 +0800 |
commit | 6c8d26d2e797e8420fc3de4b15e4c556f968aba0 (patch) | |
tree | 22beecc01da7a9ce5cac36135a89010d6d4ed4f2 /core/shard.go | |
parent | ca935bdbac190766f29fb73433a82ee5806bc8f9 (diff) | |
download | dexon-consensus-6c8d26d2e797e8420fc3de4b15e4c556f968aba0.tar dexon-consensus-6c8d26d2e797e8420fc3de4b15e4c556f968aba0.tar.gz dexon-consensus-6c8d26d2e797e8420fc3de4b15e4c556f968aba0.tar.bz2 dexon-consensus-6c8d26d2e797e8420fc3de4b15e4c556f968aba0.tar.lz dexon-consensus-6c8d26d2e797e8420fc3de4b15e4c556f968aba0.tar.xz dexon-consensus-6c8d26d2e797e8420fc3de4b15e4c556f968aba0.tar.zst dexon-consensus-6c8d26d2e797e8420fc3de4b15e4c556f968aba0.zip |
core: add debug (#133)
* Split interface
* Rename nonblocking-application to nonblocking
Parts needs nonblocking gets more.
* Implement core.nonBlocking based on interface split
* Fix: the witness parent hash could be parent on compaction chain.
* Rename Application.DeliverBlock to BlockDeliver
To sync with naming of other methods.
* Change methods' fingerprint
- BlockConfirmed provides block hash only.
- BlockDeliver provde a whole block.
Diffstat (limited to 'core/shard.go')
-rw-r--r-- | core/shard.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/core/shard.go b/core/shard.go index b6a17e1..13c73d5 100644 --- a/core/shard.go +++ b/core/shard.go @@ -36,6 +36,7 @@ type Shard struct { sigToPub SigToPubFn chainNum uint32 app Application + debug Debug db blockdb.BlockDatabase pool blockPool lattice *blockLattice @@ -50,6 +51,7 @@ func NewShard( prvKey crypto.PrivateKey, sigToPub SigToPubFn, app Application, + debug Debug, db blockdb.BlockDatabase) (s *Shard) { s = &Shard{ @@ -59,6 +61,7 @@ func NewShard( sigToPub: sigToPub, chainNum: cfg.NumChains, app: app, + debug: debug, db: db, pool: newBlockPool(cfg.NumChains), lattice: newBlockLattice(ID, cfg.NumChains), @@ -155,8 +158,10 @@ func (s *Shard) ProcessBlock( } // TODO(mission): remove this hack, BA related stuffs should not // be done here. - s.app.StronglyAcked(input.Hash) - s.app.BlockConfirmed(input) + if s.debug != nil { + s.debug.StronglyAcked(input.Hash) + s.debug.BlockConfirmed(input.Hash) + } // Purge blocks in pool with the same chainID and lower height. s.pool.purgeBlocks(input.Position.ChainID, input.Position.Height) // Replay tips in pool to check their validity. @@ -186,7 +191,9 @@ func (s *Shard) ProcessBlock( for idx := range toDelivered { hashes[idx] = toDelivered[idx].Hash } - s.app.TotalOrderingDeliver(hashes, earlyDelivered) + if s.debug != nil { + s.debug.TotalOrderingDeliver(hashes, earlyDelivered) + } // Perform timestamp generation. if err = s.ctModule.processBlocks(toDelivered); err != nil { return |