/
instances.go
51 lines (40 loc) · 1.25 KB
/
instances.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
package insight
import (
"math/rand"
"time"
"qxklmrhx7qkzais6.onion/Tochka/payaka-payment-gate/settings"
)
/*
Bitcoin
*/
var (
localInsightAPI = NewAPI(settings.PAYMENT_GATE_SETTINGS.BitcoinInsightAPIURL, false, 100)
// bitaccessInsightAPI = NewAPI("https://search.bitaccess.co/insight-api", true, 5)
bitpayInsightAPI = NewAPI("https://insight.bitpay.com/api", false, 5)
localBitcoinInsightAPI = NewAPI("https://localbitcoinschain.com/api", false, 5)
)
func multiplyAPIs(api InsightAPI, numInstances int) []InsightAPI {
apiSet := []InsightAPI{}
for i := 0; i < numInstances; i += 1 {
apiSet = append(apiSet, api)
}
return apiSet
}
func GetRandomBitcoinInsightAPI() InsightAPI {
apiSet := []InsightAPI{}
// apiSet = append(apiSet, multiplyAPIs(bitaccessInsightAPI, 5)...)
// apiSet = append(apiSet, multiplyAPIs(bitpayInsightAPI, 5)...)
// apiSet = append(apiSet, multiplyAPIs(localBitcoinInsightAPI, 5)...)
apiSet = append(apiSet, multiplyAPIs(localInsightAPI, 5)...)
rand.Seed(time.Now().Unix())
return apiSet[rand.Intn(len(apiSet))]
}
func GetAnonymizedInsightAPI() InsightAPI {
return bitpayInsightAPI
}
/*
Bitcoin Cash
*/
func GetBlockdozerBitcoinCashInsightAPI() InsightAPI {
return NewAPI("https://blockdozer.com/api", false, 5)
}