-
Notifications
You must be signed in to change notification settings - Fork 0
/
queue.go
86 lines (71 loc) · 1.59 KB
/
queue.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package DataSync
import (
"github.com/BASChain/go-bas/Bas_Ethereum"
"sync"
)
var queueOwnership = new([]Bas_Ethereum.Hash)
var queueRoot = new([]Bas_Ethereum.Hash)
var queueSub = new([]Bas_Ethereum.Hash)
var queueDns = new([]Bas_Ethereum.Hash)
var firstAppearInBlock = make(map[Bas_Ethereum.Hash]uint64)
var oLock = &sync.RWMutex{}
var rLock = &sync.RWMutex{}
var sLock = &sync.RWMutex{}
var dLock = &sync.RWMutex{}
func insertQueue(key Bas_Ethereum.Hash,queue *[]Bas_Ethereum.Hash){
if !exists(*queue,key) {
*queue = append(*queue, key)
}
}
func clearQueueO(){
oLock.Lock()
defer oLock.Unlock()
queueOwnership = new([]Bas_Ethereum.Hash)
}
func clearQueueR(){
rLock.Lock()
defer rLock.Unlock()
queueRoot = new([]Bas_Ethereum.Hash)
}
func clearQueueS(){
sLock.Lock()
defer sLock.Unlock()
queueSub = new([]Bas_Ethereum.Hash)
}
func clearQueueD(){
dLock.Lock()
defer dLock.Unlock()
queueDns = new([]Bas_Ethereum.Hash)
}
func loopOverQueueOwnership(waitGroup *sync.WaitGroup){
oLock.Lock()
defer oLock.Unlock()
for _,s:= range *queueOwnership {
go updateByQueryOwnership(s, 0)
}
waitGroup.Done()
}
func loopOverQueueRoot(waitGroup *sync.WaitGroup){
rLock.Lock()
defer rLock.Unlock()
for _,s:= range *queueRoot {
go updateByQueryRoot(s,0)
}
waitGroup.Done()
}
func loopOverQueueSub(waitGroup *sync.WaitGroup){
sLock.Lock()
defer sLock.Unlock()
for _,s:= range *queueSub {
go updateByQuerySub(s,0)
}
waitGroup.Done()
}
func loopOverQueueDns(waitGroup *sync.WaitGroup){
dLock.Lock()
defer dLock.Unlock()
for _,s:= range *queueDns {
go updateByQueryDNS(s,0)
}
waitGroup.Done()
}