les, light: improve txstatus retrieval (#22349)

Transaction unindexing will be enabled by default as of 1.10, which causes tx status retrieval will be broken without this PR. 

This PR introduces a retry mechanism in TxStatus retrieval.
This commit is contained in:
gary rong
2021-02-25 21:24:04 +08:00
committed by GitHub
parent 378e961d85
commit 7a3c890009
14 changed files with 779 additions and 245 deletions

View File

@ -28,19 +28,26 @@ import (
)
func TestLightPruner(t *testing.T) {
config := light.TestClientIndexerConfig
waitIndexers := func(cIndexer, bIndexer, btIndexer *core.ChainIndexer) {
for {
cs, _, _ := cIndexer.Sections()
bts, _, _ := btIndexer.Sections()
if cs >= 3 && bts >= 3 {
break
var (
waitIndexers = func(cIndexer, bIndexer, btIndexer *core.ChainIndexer) {
for {
cs, _, _ := cIndexer.Sections()
bts, _, _ := btIndexer.Sections()
if cs >= 3 && bts >= 3 {
break
}
time.Sleep(10 * time.Millisecond)
}
time.Sleep(10 * time.Millisecond)
}
}
server, client, tearDown := newClientServerEnv(t, int(3*config.ChtSize+config.ChtConfirms), 2, waitIndexers, nil, 0, false, true, false)
config = light.TestClientIndexerConfig
netconfig = testnetConfig{
blocks: int(3*config.ChtSize + config.ChtConfirms),
protocol: 3,
indexFn: waitIndexers,
connect: true,
}
)
server, client, tearDown := newClientServerEnv(t, netconfig)
defer tearDown()
// checkDB iterates the chain with given prefix, resolves the block number