mirror of
https://github.com/guggero/chantools.git
synced 2026-08-13 12:33:34 +02:00
Merge pull request #212 from guggero/catch-server-error
zombierecovery: catch another server error for re-try
This commit is contained in:
commit
bc5a1d778a
1 changed files with 19 additions and 1 deletions
|
|
@ -379,7 +379,7 @@ func fetchChannels(client *graphql.Client, pubkey string) ([]*gqChannel,
|
|||
var query gqGetNodeQuery
|
||||
err := client.Query(context.Background(), &query, variables)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "Too many requests") {
|
||||
if isServerErr(err) {
|
||||
time.Sleep(1 * time.Second)
|
||||
continue
|
||||
}
|
||||
|
|
@ -401,6 +401,24 @@ func fetchChannels(client *graphql.Client, pubkey string) ([]*gqChannel,
|
|||
return channels, nil
|
||||
}
|
||||
|
||||
func isServerErr(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
errStr := err.Error()
|
||||
switch {
|
||||
case strings.Contains(errStr, "Too many requests"):
|
||||
return true
|
||||
|
||||
case strings.Contains(errStr, "error code: 520"):
|
||||
return true
|
||||
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func identifyPeer(channel *gqChannel, node1 string) string {
|
||||
if channel.Node1 == node1 {
|
||||
return channel.Node2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue