aboutsummaryrefslogtreecommitdiffstats
path: root/light
diff options
context:
space:
mode:
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
+}