problem: OutOfBound array access
This commit is contained in:
@@ -48,10 +48,10 @@ class ChainConnect(
|
|||||||
}
|
}
|
||||||
|
|
||||||
class SingleApi(
|
class SingleApi(
|
||||||
val quorumApi: QuorumApi
|
private val quorumApi: QuorumApi
|
||||||
): Iterator<EthereumApi> {
|
): Iterator<EthereumApi> {
|
||||||
|
|
||||||
var consumed = false
|
private var consumed = false
|
||||||
|
|
||||||
override fun hasNext(): Boolean {
|
override fun hasNext(): Boolean {
|
||||||
return !consumed && quorumApi.hasNext()
|
return !consumed && quorumApi.hasNext()
|
||||||
@@ -64,12 +64,12 @@ class ChainConnect(
|
|||||||
}
|
}
|
||||||
|
|
||||||
class QuorumApi(
|
class QuorumApi(
|
||||||
val apis: List<Upstream>,
|
private val apis: List<Upstream>,
|
||||||
val quorum: Int,
|
private val quorum: Int,
|
||||||
var pos: Int
|
private var pos: Int
|
||||||
): Iterator<EthereumApi> {
|
): Iterator<EthereumApi> {
|
||||||
|
|
||||||
var consumed = 0
|
private var consumed = 0
|
||||||
|
|
||||||
override fun hasNext(): Boolean {
|
override fun hasNext(): Boolean {
|
||||||
return consumed < quorum
|
return consumed < quorum
|
||||||
@@ -78,7 +78,7 @@ class ChainConnect(
|
|||||||
override fun next(): EthereumApi {
|
override fun next(): EthereumApi {
|
||||||
val start = pos
|
val start = pos
|
||||||
while (pos < start + apis.size) {
|
while (pos < start + apis.size) {
|
||||||
val api = apis[pos++]
|
val api = apis[pos++ % apis.size]
|
||||||
if (api.isAvailable()) {
|
if (api.isAvailable()) {
|
||||||
consumed++
|
consumed++
|
||||||
return api.api
|
return api.api
|
||||||
|
|||||||
Reference in New Issue
Block a user