aboutsummaryrefslogtreecommitdiffstats
path: root/core/lattice.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2019-01-23 15:02:42 +0800
committerGitHub <noreply@github.com>2019-01-23 15:02:42 +0800
commit0e6dc8b38f7df249831aebd4928ec42b827038e3 (patch)
tree29966ef1a69ed7431dbac461049338056f0717da /core/lattice.go
parentca43bd9f99deead21dae71a749297dc6aa361898 (diff)
downloaddexon-consensus-0e6dc8b38f7df249831aebd4928ec42b827038e3.tar
dexon-consensus-0e6dc8b38f7df249831aebd4928ec42b827038e3.tar.gz
dexon-consensus-0e6dc8b38f7df249831aebd4928ec42b827038e3.tar.bz2
dexon-consensus-0e6dc8b38f7df249831aebd4928ec42b827038e3.tar.lz
dexon-consensus-0e6dc8b38f7df249831aebd4928ec42b827038e3.tar.xz
dexon-consensus-0e6dc8b38f7df249831aebd4928ec42b827038e3.tar.zst
dexon-consensus-0e6dc8b38f7df249831aebd4928ec42b827038e3.zip
core: optimize core (#428)
* core: Use a channel to process ba confirmed block * change the implementation of done() to react faster * Fix restart * Wait tipRound to change * fix corner case * Check for context
Diffstat (limited to 'core/lattice.go')
-rw-r--r--core/lattice.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/core/lattice.go b/core/lattice.go
index d531639..de0e549 100644
--- a/core/lattice.go
+++ b/core/lattice.go
@@ -290,6 +290,13 @@ func (l *Lattice) NextBlock(round uint64, chainID uint32) (
return l.data.nextBlock(round, chainID)
}
+// TipRound returns the round of the tip of given chain.
+func (l *Lattice) TipRound(chainID uint32) uint64 {
+ l.lock.RLock()
+ defer l.lock.RUnlock()
+ return l.data.tipRound(chainID)
+}
+
// PurgeBlocks purges blocks' cache in memory, this is called when the caller
// makes sure those blocks are already saved in db.
func (l *Lattice) PurgeBlocks(blocks []*types.Block) error {