Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MX-14354: snapshotless observers support #388

5 changes: 2 additions & 3 deletions api/groups/baseNetworkGroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/multiversx/mx-chain-proxy-go/api/errors"
"github.com/multiversx/mx-chain-proxy-go/api/shared"
"github.com/multiversx/mx-chain-proxy-go/data"
"github.com/multiversx/mx-chain-proxy-go/process"
)

type networkGroup struct {
Expand Down Expand Up @@ -55,7 +54,7 @@ func NewNetworkGroup(facadeHandler data.FacadeHandler) (*networkGroup, error) {
func (group *networkGroup) getNetworkStatusData(c *gin.Context) {
shardIDUint, err := shared.FetchShardIDFromRequest(c)
if err != nil {
shared.RespondWith(c, http.StatusBadRequest, nil, process.ErrInvalidShardId.Error(), data.ReturnCodeRequestError)
shared.RespondWith(c, http.StatusBadRequest, nil, errors.ErrInvalidShardIDParam.Error(), data.ReturnCodeRequestError)
return
}

Expand Down Expand Up @@ -204,7 +203,7 @@ func (group *networkGroup) getGasConfigs(c *gin.Context) {
func (group *networkGroup) getTrieStatistics(c *gin.Context) {
shardID, err := shared.FetchShardIDFromRequest(c)
if err != nil {
shared.RespondWith(c, http.StatusBadRequest, nil, process.ErrInvalidShardId.Error(), data.ReturnCodeRequestError)
shared.RespondWith(c, http.StatusBadRequest, nil, errors.ErrInvalidShardIDParam.Error(), data.ReturnCodeRequestError)
return
}

Expand Down
2 changes: 2 additions & 0 deletions cmd/proxy/config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@
# List of Observers. If you want to define a metachain observer (needed for validator statistics route) use
# shard id 4294967295
# Fallback observers which are only used when regular ones are offline should have IsFallback = true
# Snapshotless observers are observers that can only respond to real-time requests, such as vm queries. They should have IsSnapshotless = true
[[Observers]]
ShardId = 0
Address = "http://127.0.0.1:8081"
IsSnapshotless = true

[[Observers]]
ShardId = 1
Expand Down
9 changes: 9 additions & 0 deletions common/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ type AccountQueryOptions struct {
HintEpoch core.OptionalUint32
}

// AreHistoricalCoordinatesSet returns true if historical block coordinates are set
func (a AccountQueryOptions) AreHistoricalCoordinatesSet() bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unit test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

return a.BlockNonce.HasValue ||
a.OnStartOfEpoch.HasValue ||
a.HintEpoch.HasValue ||
len(a.BlockHash) > 0 ||
len(a.BlockRootHash) > 0
}

// BuildUrlWithAccountQueryOptions builds an URL with block query parameters
func BuildUrlWithAccountQueryOptions(path string, options AccountQueryOptions) string {
u := url.URL{Path: path}
Expand Down
20 changes: 16 additions & 4 deletions data/observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package data

// NodeData holds an observer data
type NodeData struct {
ShardId uint32
Address string
IsSynced bool
IsFallback bool
ShardId uint32
Address string
IsSynced bool
IsFallback bool
IsSnapshotless bool
}

// NodesReloadResponse is a DTO that holds details about nodes reloading
Expand All @@ -25,3 +26,14 @@ const (
// FullHistoryNode identifier a node that has full history mode enabled
FullHistoryNode NodeType = "full history"
)

// ObserverDataAvailabilityType represents the type to be used for the observers' data availability
type ObserverDataAvailabilityType string

const (
// AvailabilityAll mean that the observer can be used for both real-time and historical requests
AvailabilityAll ObserverDataAvailabilityType = "all"

// AvailabilityRecent means that the observer can be used only for recent data
AvailabilityRecent ObserverDataAvailabilityType = "recent"
)
Loading
Loading