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

Merge spica relayed into sovereign 31 ian #478

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ae8048e
- fixed the URL parameter for hint epoch
iulianpascalau Oct 16, 2024
b44efd7
Merge branch 'rc/v1.7.next1' into fixed-url-parameter-hint-epoch
sstanculeanu Oct 16, 2024
9c7ed13
new relayed v3
sstanculeanu Oct 29, 2024
eb1c68f
fix process-status for relayed v3 of type move balance
sstanculeanu Nov 22, 2024
5beaec3
Merge branch 'rc/spica-patch-relayedv3' of https://github.com/multive…
sstanculeanu Dec 4, 2024
bdfafdc
updated core-go after merge
sstanculeanu Dec 4, 2024
f6a041e
new flag, no status check
sstanculeanu Dec 13, 2024
de822ec
Merge pull request #473 from multiversx/no_status_check
sstanculeanu Dec 18, 2024
cb899f2
Merge branch 'rc/spica-patch-relayedv3' into relayedv3
sstanculeanu Dec 18, 2024
52467cf
new parameter
miiu96 Dec 23, 2024
541b3d0
Update common/options.go
miiu96 Dec 27, 2024
bda1e8e
Merge branch 'rc/spica-patch-relayedv3' into hyper-block-new-parameter
miiu96 Dec 27, 2024
dd444df
parse forHyperblock from block request too
sstanculeanu Jan 9, 2025
ffc3f61
Merge pull request #475 from multiversx/hyper-block-new-parameter
AdoAdoAdo Jan 9, 2025
6705362
updated deps after merge
sstanculeanu Jan 9, 2025
0a7ed7b
Merge branch 'rc/spica-patch-relayedv3' into relayedv3
sstanculeanu Jan 9, 2025
4c13d52
Merge pull request #468 from multiversx/relayedv3
sstanculeanu Jan 16, 2025
a37cbb2
updated deps
sstanculeanu Jan 16, 2025
2b25b7b
Merge pull request #476 from multiversx/update_deps
sstanculeanu Jan 16, 2025
d13bd04
Merge branch 'rc/v1.7.next1' into fixed-url-parameter-hint-epoch
andreibancioiu Jan 16, 2025
485df81
Merge branch 'master' into fixed-url-parameter-hint-epoch
andreibancioiu Jan 16, 2025
b0c42dd
Merge branch 'rc/spica-patch-relayedv3' into fixed-url-parameter-hint…
iulianpascalau Jan 16, 2025
f962d53
Merge pull request #466 from multiversx/fixed-url-parameter-hint-epoch
sstanculeanu Jan 16, 2025
e46145c
Merge remote-tracking branch 'origin/rc/spica-patch-relayedv3' into m…
axenteoctavian Jan 31, 2025
26d4abd
sovereign go.mod, update tx notarization checker for relayed v3
axenteoctavian Jan 31, 2025
1e00a52
go mod indexer update
axenteoctavian Jan 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions api/groups/urlParams.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ func parseBlockQueryOptions(c *gin.Context) (common.BlockQueryOptions, error) {
return common.BlockQueryOptions{}, err
}

options := common.BlockQueryOptions{WithTransactions: withTxs, WithLogs: withLogs}
forHyperblock, err := parseBoolUrlParam(c, common.UrlParameterForHyperblock)
if err != nil {
return common.BlockQueryOptions{}, err
}

options := common.BlockQueryOptions{WithTransactions: withTxs, WithLogs: withLogs, ForHyperblock: forHyperblock}
return options, nil
}

Expand Down Expand Up @@ -85,7 +90,7 @@ func parseAccountQueryOptions(c *gin.Context, address string) (common.AccountQue
return common.AccountQueryOptions{}, err
}

hintEpoch, err := parseUint32UrlParam(c, common.UrlParameterOnStartOfEpoch)
hintEpoch, err := parseUint32UrlParam(c, common.UrlParameterHintEpoch)
if err != nil {
return common.AccountQueryOptions{}, err
}
Expand Down
23 changes: 20 additions & 3 deletions api/groups/urlParams_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,41 @@ import (
"testing"

"github.com/gin-gonic/gin"
"github.com/multiversx/mx-chain-core-go/core"
"github.com/multiversx/mx-chain-proxy-go/common"
"github.com/stretchr/testify/require"
)

func TestParseBlockQueryOptions(t *testing.T) {
options, err := parseBlockQueryOptions(createDummyGinContextWithQuery("withTxs=true&withLogs=true"))
t.Parallel()

options, err := parseBlockQueryOptions(createDummyGinContextWithQuery("withTxs=true&withLogs=true&forHyperblock=true"))
require.Nil(t, err)
require.Equal(t, common.BlockQueryOptions{WithTransactions: true, WithLogs: true}, options)
require.Equal(t, common.BlockQueryOptions{WithTransactions: true, WithLogs: true, ForHyperblock: true}, options)

options, err = parseBlockQueryOptions(createDummyGinContextWithQuery("withTxs=true"))
require.Nil(t, err)
require.Equal(t, common.BlockQueryOptions{WithTransactions: true, WithLogs: false}, options)
require.Equal(t, common.BlockQueryOptions{WithTransactions: true, WithLogs: false, ForHyperblock: false}, options)

options, err = parseBlockQueryOptions(createDummyGinContextWithQuery("withTxs=foobar"))
require.NotNil(t, err)
require.Empty(t, options)
}

func TestParseAccountOptions(t *testing.T) {
t.Parallel()

expectedOptions := common.AccountQueryOptions{
HintEpoch: core.OptionalUint32{
Value: 3737,
HasValue: true,
},
}
options, err := parseAccountQueryOptions(createDummyGinContextWithQuery("hintEpoch=3737"), "")
require.Nil(t, err)
require.Equal(t, expectedOptions, options)
}

func TestParseHyperblockQueryOptions(t *testing.T) {
t.Parallel()

Expand Down
4 changes: 2 additions & 2 deletions cmd/proxy/config/swagger/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@
}
}
},
"/block/{shard}/by-nonce/{nonce}?withTxs=true": {
"/block/{shard}/by-nonce/{nonce}?withTxs=true&withLogs=true&forHyperblock=true": {
"get": {
"tags": [
"block"
Expand Down Expand Up @@ -725,7 +725,7 @@
}
}
},
"/block/{shard}/by-hash/{hash}?withTxs=true": {
"/block/{shard}/by-hash/{hash}?withTxs=true&withLogs=true&forHyperblock=true": {
"get": {
"tags": [
"block"
Expand Down
15 changes: 14 additions & 1 deletion cmd/proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ VERSION:
Name: "start-swagger-ui",
Usage: "If set to true, will start a Swagger UI on the root",
}
// noStatusCheck defines a flag that specifies if the status checks for the observers should be skipped
noStatusCheck = cli.BoolFlag{
Name: "no-status-check",
Usage: "If set to true, will skip the status check for observers, treating them as always synced. ⚠️ This relies on proper " +
"observers management on the provider side.",
}
// sovereign defines a flag that specifies if what run type components should use
sovereign = cli.BoolFlag{
Name: "sovereign",
Expand Down Expand Up @@ -192,6 +198,7 @@ func main() {
workingDirectory,
memBallast,
startSwaggerUI,
noStatusCheck,
sovereign,
}
app.Authors = []cli.Author{
Expand Down Expand Up @@ -282,7 +289,8 @@ func startProxy(ctx *cli.Context) error {
statusMetricsProvider := metrics.NewStatusMetrics()

shouldStartSwaggerUI := ctx.GlobalBool(startSwaggerUI.Name)
versionsRegistry, err := createVersionsRegistryTestOrProduction(ctx, generalConfig, configurationFileName, statusMetricsProvider, closableComponents)
skipStatusCheck := ctx.GlobalBool(noStatusCheck.Name)
versionsRegistry, err := createVersionsRegistryTestOrProduction(ctx, generalConfig, configurationFileName, statusMetricsProvider, closableComponents, skipStatusCheck)
if err != nil {
return err
}
Expand Down Expand Up @@ -318,6 +326,7 @@ func createVersionsRegistryTestOrProduction(
configurationFilePath string,
statusMetricsHandler data.StatusMetricsProvider,
closableComponents *data.ClosableComponentsHandler,
skipStatusCheck bool,
) (data.VersionsRegistryHandler, error) {

var testHTTPServerEnabled bool
Expand Down Expand Up @@ -383,6 +392,7 @@ func createVersionsRegistryTestOrProduction(
ctx.GlobalString(apiConfigDirectory.Name),
ctx.GlobalBool(sovereign.Name),
closableComponents,
skipStatusCheck,
)
}

Expand All @@ -394,6 +404,7 @@ func createVersionsRegistryTestOrProduction(
ctx.GlobalString(apiConfigDirectory.Name),
ctx.GlobalBool(sovereign.Name),
closableComponents,
skipStatusCheck,
)
}

Expand All @@ -405,6 +416,7 @@ func createVersionsRegistry(
apiConfigDirectoryPath string,
isSovereignConfig bool,
closableComponents *data.ClosableComponentsHandler,
skipStatusCheck bool,
) (data.VersionsRegistryHandler, error) {
pubKeyConverter, err := pubkeyConverter.NewBech32PubkeyConverter(cfg.AddressPubkeyConverter.Length, addressHRP)
if err != nil {
Expand Down Expand Up @@ -453,6 +465,7 @@ func createVersionsRegistry(
observersProvider,
fullHistoryNodesProvider,
pubKeyConverter,
skipStatusCheck,
)
if err != nil {
return nil, err
Expand Down
6 changes: 6 additions & 0 deletions common/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const (
UrlParameterWithTransactions = "withTxs"
// UrlParameterWithLogs represents the name of an URL parameter
UrlParameterWithLogs = "withLogs"
// UrlParameterForHyperblock represents the name of an URL parameter
UrlParameterForHyperblock = "forHyperblock"
// UrlParameterNotarizedAtSource represents the name of an URL parameter
UrlParameterNotarizedAtSource = "notarizedAtSource"
// UrlParameterOnFinalBlock represents the name of an URL parameter
Expand Down Expand Up @@ -55,6 +57,7 @@ const (
type BlockQueryOptions struct {
WithTransactions bool
WithLogs bool
ForHyperblock bool
}

// HyperblockQueryOptions holds options for hyperblock queries
Expand Down Expand Up @@ -100,6 +103,9 @@ func BuildUrlWithBlockQueryOptions(path string, options BlockQueryOptions) strin
if options.WithLogs {
query.Set(UrlParameterWithLogs, "true")
}
if options.ForHyperblock {
query.Set(UrlParameterForHyperblock, "true")
}

u.RawQuery = query.Encode()
return u.String()
Expand Down
2 changes: 2 additions & 0 deletions common/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ func TestBuildUrlWithBlockQueryOptions_ShouldWork(t *testing.T) {
builtUrl = BuildUrlWithBlockQueryOptions("/block/by-nonce/15", BlockQueryOptions{
WithTransactions: true,
WithLogs: true,
ForHyperblock: true,
})
parsed, err := url.Parse(builtUrl)
require.Nil(t, err)
require.Equal(t, "/block/by-nonce/15", parsed.Path)
require.Equal(t, "true", parsed.Query().Get("withTxs"))
require.Equal(t, "true", parsed.Query().Get("withLogs"))
require.Equal(t, "true", parsed.Query().Get("forHyperblock"))
}

func TestBuildUrlWithAccountQueryOptions_ShouldWork(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions data/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ type Transaction struct {
Options uint32 `json:"options,omitempty"`
GuardianAddr string `json:"guardian,omitempty"`
GuardianSignature string `json:"guardianSignature,omitempty"`
RelayerAddr string `json:"relayer,omitempty"`
RelayerSignature string `json:"relayerSignature,omitempty"`
}

// GetTransactionResponseData follows the format of the data field of get transaction response
Expand Down
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ require (
github.com/gin-contrib/pprof v1.4.0
github.com/gin-contrib/static v0.0.1
github.com/gin-gonic/gin v1.9.1
github.com/multiversx/mx-chain-core-go v1.2.23
github.com/multiversx/mx-chain-core-go v1.2.25-0.20250131091121-26781bb55fe9
github.com/multiversx/mx-chain-crypto-go v1.2.12
github.com/multiversx/mx-chain-es-indexer-go v1.7.8
github.com/multiversx/mx-chain-es-indexer-go v1.7.15-0.20250131092302-72295e5fa14c
github.com/multiversx/mx-chain-logger-go v1.0.15
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.8.4
Expand Down Expand Up @@ -47,11 +47,11 @@ require (
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/crypto v0.9.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/net v0.16.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
28 changes: 14 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o=
github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
github.com/multiversx/mx-chain-core-go v1.2.23 h1:8WlCGqJHR2HQ0vN4feJwb7W4VrCwBGIzPPHunOOg5Wc=
github.com/multiversx/mx-chain-core-go v1.2.23/go.mod h1:B5zU4MFyJezmEzCsAHE9YNULmGCm2zbPHvl9hazNxmE=
github.com/multiversx/mx-chain-core-go v1.2.25-0.20250131091121-26781bb55fe9 h1:hm9b1I3ywGV6vOMFX86sZ5jZ7hdIqq1IH8EPNj0Pliw=
github.com/multiversx/mx-chain-core-go v1.2.25-0.20250131091121-26781bb55fe9/go.mod h1:P/YBoFnt25XUaCQ7Q/SD15vhnc9yV5JDhHxyFO9P8Z0=
github.com/multiversx/mx-chain-crypto-go v1.2.12 h1:zWip7rpUS4CGthJxfKn5MZfMfYPjVjIiCID6uX5BSOk=
github.com/multiversx/mx-chain-crypto-go v1.2.12/go.mod h1:HzcPpCm1zanNct/6h2rIh+MFrlXbjA5C8+uMyXj3LI4=
github.com/multiversx/mx-chain-es-indexer-go v1.7.8 h1:ZDKTXkQhQ7lLi6huVrBTUssVEqCvaCxGH4Y52GapboQ=
github.com/multiversx/mx-chain-es-indexer-go v1.7.8/go.mod h1:oGcRK2E3Syv6vRTszWrrb/TqD8akq0yeoMr1wPPiTO4=
github.com/multiversx/mx-chain-es-indexer-go v1.7.15-0.20250131092302-72295e5fa14c h1:i+V8WhfzvHYoJ8HDEDO1cqRl8sF0xJGUtRP0hc/cfbQ=
github.com/multiversx/mx-chain-es-indexer-go v1.7.15-0.20250131092302-72295e5fa14c/go.mod h1:u3P9JM8JWPRcYW3X0Lsw06Nf6a6M7cS42XwT4Au/Ar8=
github.com/multiversx/mx-chain-logger-go v1.0.15 h1:HlNdK8etyJyL9NQ+6mIXyKPEBo+wRqOwi3n+m2QIHXc=
github.com/multiversx/mx-chain-logger-go v1.0.15/go.mod h1:t3PRKaWB1M+i6gUfD27KXgzLJJC+mAQiN+FLlL1yoGQ=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
Expand Down Expand Up @@ -198,8 +198,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g=
golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0=
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand All @@ -211,8 +211,8 @@ golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.16.0 h1:7eBu7KsSvFDtSXUIDbh3aqlK4DPsZ1rByC8PFfBThos=
golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand All @@ -234,15 +234,15 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
Expand All @@ -260,8 +260,8 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
Expand Down
9 changes: 9 additions & 0 deletions observer/baseNodeProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ func (bnp *baseNodeProvider) UpdateNodesBasedOnSyncState(nodesWithSyncStatus []*
bnp.snapshotlessNodes.UpdateNodes(snapshotlessNodes)
}

// PrintNodesInShards will only print the nodes in shards
func (bnp *baseNodeProvider) PrintNodesInShards() {
bnp.mutNodes.RLock()
defer bnp.mutNodes.RUnlock()

bnp.regularNodes.PrintNodesInShards()
bnp.snapshotlessNodes.PrintNodesInShards()
}

func splitNodesByDataAvailability(nodes []*data.NodeData) ([]*data.NodeData, []*data.NodeData) {
regularNodes := make([]*data.NodeData, 0)
snapshotlessNodes := make([]*data.NodeData, 0)
Expand Down
4 changes: 4 additions & 0 deletions observer/disabledNodesProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ func (d *disabledNodesProvider) ReloadNodes(_ data.NodeType) data.NodesReloadRes
return data.NodesReloadResponse{Description: "disabled nodes provider", Error: d.returnMessage}
}

// PrintNodesInShards does nothing as it is disabled
func (d *disabledNodesProvider) PrintNodesInShards() {
}

// IsInterfaceNil returns true if there is no value under the interface
func (d *disabledNodesProvider) IsInterfaceNil() bool {
return d == nil
Expand Down
8 changes: 8 additions & 0 deletions observer/holder/nodesHolder.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ func (nh *nodesHolder) UpdateNodes(nodesWithSyncStatus []*data.NodeData) {
nh.printNodesInShardsUnprotected()
}

// PrintNodesInShards will only print the nodes in shards
func (nh *nodesHolder) PrintNodesInShards() {
nh.mut.RLock()
defer nh.mut.RUnlock()

nh.printNodesInShardsUnprotected()
}

// GetSyncedNodes returns all the synced nodes
func (nh *nodesHolder) GetSyncedNodes(shardID uint32) []*data.NodeData {
return nh.getObservers(syncedNodesCache, shardID)
Expand Down
2 changes: 2 additions & 0 deletions observer/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ type NodesProviderHandler interface {
UpdateNodesBasedOnSyncState(nodesWithSyncStatus []*data.NodeData)
GetAllNodesWithSyncState() []*data.NodeData
ReloadNodes(nodesType data.NodeType) data.NodesReloadResponse
PrintNodesInShards()
IsInterfaceNil() bool
}

// NodesHolder defines the actions of a component that is able to hold nodes
type NodesHolder interface {
UpdateNodes(nodesWithSyncStatus []*data.NodeData)
PrintNodesInShards()
GetSyncedNodes(shardID uint32) []*data.NodeData
GetSyncedFallbackNodes(shardID uint32) []*data.NodeData
GetOutOfSyncNodes(shardID uint32) []*data.NodeData
Expand Down
Loading
Loading