-
Notifications
You must be signed in to change notification settings - Fork 501
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
services/horizon: Return 503 error in POST /transactions if Stellar-C…
…ore not synced (#3653) This commit changes `POST /transactions` behaviour to return `503 Service Unavailable` (`stale_history`) instead of `504 Gateway Timeout` (`timeout`) response if connected Stellar-Core is not synced. `timeout` error is confusing when the connected Stellar-Core is not synced because it means that the transaction has been broadcasted but there is no result yet. What actually happens is that the transaction is not broadcasted (and Horizon cannot ingest it) when Stellar-Core is not in synced. The new response is returned as soon as Horizon determines that the Stellar-Core status has changed.
- Loading branch information
Showing
9 changed files
with
91 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package corestate | ||
|
||
import ( | ||
"sync" | ||
|
||
"github.com/stellar/go/protocols/stellarcore" | ||
) | ||
|
||
type State struct { | ||
Synced bool | ||
CurrentProtocolVersion int32 | ||
CoreSupportedProtocolVersion int32 | ||
CoreVersion string | ||
} | ||
|
||
type Store struct { | ||
sync.RWMutex | ||
state State | ||
} | ||
|
||
func (c *Store) Set(resp *stellarcore.InfoResponse) { | ||
c.Lock() | ||
defer c.Unlock() | ||
c.state.Synced = resp.IsSynced() | ||
c.state.CoreVersion = resp.Info.Build | ||
c.state.CurrentProtocolVersion = int32(resp.Info.Ledger.Version) | ||
c.state.CoreSupportedProtocolVersion = int32(resp.Info.ProtocolVersion) | ||
} | ||
|
||
func (c *Store) SetState(state State) { | ||
c.Lock() | ||
defer c.Unlock() | ||
c.state = state | ||
} | ||
|
||
func (c *Store) Get() State { | ||
c.RLock() | ||
defer c.RUnlock() | ||
return c.state | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters