aboutsummaryrefslogtreecommitdiffstats
path: root/light
diff options
context:
space:
mode:
authorb00ris <b00ris@mail.ru>2019-01-24 19:18:26 +0800
committerFelix Lange <fjl@users.noreply.github.com>2019-01-24 19:18:26 +0800
commit769657060e888612e7d585c6b6eae16a64c4ad19 (patch)
tree12d6b3dad5209d35972d3569b5ff56ad55363b40 /light
parentb8f9b3779fbdc62d5a935b57f1360608fa4600b4 (diff)
downloadgo-tangerine-769657060e888612e7d585c6b6eae16a64c4ad19.tar
go-tangerine-769657060e888612e7d585c6b6eae16a64c4ad19.tar.gz
go-tangerine-769657060e888612e7d585c6b6eae16a64c4ad19.tar.bz2
go-tangerine-769657060e888612e7d585c6b6eae16a64c4ad19.tar.lz
go-tangerine-769657060e888612e7d585c6b6eae16a64c4ad19.tar.xz
go-tangerine-769657060e888612e7d585c6b6eae16a64c4ad19.tar.zst
go-tangerine-769657060e888612e7d585c6b6eae16a64c4ad19.zip
les: implement ultralight client (#16904)
For more information about this light client mode, read https://hackmd.io/s/HJy7jjZpm
Diffstat (limited to 'light')
-rw-r--r--light/lightchain.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/light/lightchain.go b/light/lightchain.go
index de3d583c7..47161c9ef 100644
--- a/light/lightchain.go
+++ b/light/lightchain.go
@@ -70,6 +70,8 @@ type LightChain struct {
wg sync.WaitGroup
engine consensus.Engine
+
+ disableCheckFreq bool
}
// NewLightChain returns a fully initialised light chain using information
@@ -354,6 +356,9 @@ func (self *LightChain) postChainEvents(events []interface{}) {
// In the case of a light chain, InsertHeaderChain also creates and posts light
// chain events when necessary.
func (self *LightChain) InsertHeaderChain(chain []*types.Header, checkFreq int) (int, error) {
+ if self.disableCheckFreq {
+ checkFreq = 0
+ }
start := time.Now()
if i, err := self.hc.ValidateHeaderChain(chain, checkFreq); err != nil {
return i, err
@@ -526,3 +531,17 @@ func (self *LightChain) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscri
func (self *LightChain) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent) event.Subscription {
return self.scope.Track(new(event.Feed).Subscribe(ch))
}
+
+//DisableCheckFreq disables header validation. It needs for ULC
+func (self *LightChain) DisableCheckFreq() {
+ self.mu.Lock()
+ defer self.mu.Unlock()
+ self.disableCheckFreq = true
+}
+
+//EnableCheckFreq enables header validation
+func (self *LightChain) EnableCheckFreq() {
+ self.mu.Lock()
+ defer self.mu.Unlock()
+ self.disableCheckFreq = false
+}