Skip to content

Commit f8ca38d

Browse files
RainFallsSilentttblack
authored andcommittedSep 9, 2024
feat: update spv to add isCurrent check
1 parent 04fafc2 commit f8ca38d

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed
 

‎go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require (
1717
github.com/edsrzf/mmap-go v1.1.0
1818
github.com/elastic/gosigar v0.14.2
1919
github.com/elastos/Elastos.ELA v0.9.8-0.20230822071649-363670e32ee4
20-
github.com/elastos/Elastos.ELA.SPV v0.1.1-0.20231107083705-d031e6862297
20+
github.com/elastos/Elastos.ELA.SPV v0.1.1-0.20240904064254-31ee1cd78518
2121
github.com/fatih/color v1.13.0
2222
github.com/fjl/memsize v0.0.1
2323
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08

‎spv/blocklistener.go

+18-12
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,30 @@ type BlockListener struct {
3434
dynamicArbiterHeight uint64
3535
}
3636

37-
func (l *BlockListener) NotifyBlock(block *util.Block) {
38-
if block.Height <= l.blockNumber {
39-
log.Warn("BlockListener handle block ", "height", l.blockNumber)
40-
return
41-
}
42-
l.blockNumber = block.Height
43-
l.StoreAuxBlock(block)
44-
log.Info("BlockListener handle block ", "height", l.blockNumber, "l.dynamicArbiterHeight ", l.dynamicArbiterHeight)
37+
func (l *BlockListener) NotifyBlock(block *util.Block, isCurrent bool) {
38+
if isCurrent {
39+
if block.Height <= l.blockNumber {
40+
log.Warn("BlockListener handle block ", "height", l.blockNumber)
41+
return
42+
}
43+
l.blockNumber = block.Height
44+
l.StoreAuxBlock(block)
45+
log.Info("BlockListener handle block ", "height", l.blockNumber, "l.dynamicArbiterHeight ", l.dynamicArbiterHeight)
4546

46-
if uint64(l.blockNumber) < l.dynamicArbiterHeight {
47-
return
47+
if uint64(l.blockNumber) < l.dynamicArbiterHeight {
48+
return
49+
}
50+
51+
l.onBlockHandled(l.param.block)
4852
}
4953

50-
l.onBlockHandled(l.param.block)
5154
if l.handle != nil {
5255
l.handle(l.param.block)
5356
}
54-
events.Notify(dpos.ETOnSPVHeight, l.blockNumber)
57+
58+
if isCurrent {
59+
events.Notify(dpos.ETOnSPVHeight, l.blockNumber)
60+
}
5561
}
5662

5763
func (l *BlockListener) BlockHeight() uint32 {

0 commit comments

Comments
 (0)
Please sign in to comment.