-
Notifications
You must be signed in to change notification settings - Fork 205
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
Index incoming tokens #6736
base: feat/chain-go-sdk
Are you sure you want to change the base?
Index incoming tokens #6736
Changes from all commits
a62d85b
340e464
804da76
a171435
4c17ba5
4380d51
983c039
a79b1a5
c8b2623
723364c
7fe8b76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,10 @@ package config | |
|
||
// ExternalConfig will hold the configurations for external tools, such as Explorer or Elasticsearch | ||
type ExternalConfig struct { | ||
ElasticSearchConnector ElasticSearchConfig | ||
EventNotifierConnector EventNotifierConfig | ||
HostDriversConfig []HostDriversConfig | ||
ElasticSearchConnector ElasticSearchConfig | ||
MainChainElasticSearchConnector MainChainElasticSearchConfig | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a preference, if you add something new, can you please There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I used the sections order from the .toml file... |
||
EventNotifierConnector EventNotifierConfig | ||
HostDriversConfig []HostDriversConfig | ||
} | ||
|
||
// ElasticSearchConfig will hold the configuration for the elastic search | ||
|
@@ -19,6 +20,14 @@ type ElasticSearchConfig struct { | |
EnabledIndexes []string | ||
} | ||
|
||
// MainChainElasticSearchConfig will hold the configuration for the main chain elastic search | ||
type MainChainElasticSearchConfig struct { | ||
Enabled bool | ||
URL string | ||
Username string | ||
Password string | ||
} | ||
|
||
// EventNotifierConfig will hold the configuration for the events notifier driver | ||
type EventNotifierConfig struct { | ||
Enabled bool | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import ( | |
"github.com/multiversx/mx-chain-core-go/core" | ||
"github.com/multiversx/mx-chain-core-go/core/check" | ||
factoryMarshalizer "github.com/multiversx/mx-chain-core-go/marshal/factory" | ||
esFactory "github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/factory" | ||
indexerFactory "github.com/multiversx/mx-chain-es-indexer-go/process/factory" | ||
logger "github.com/multiversx/mx-chain-logger-go" | ||
|
||
|
@@ -47,6 +48,7 @@ type StatusComponentsFactoryArgs struct { | |
CryptoComponents factory.CryptoComponentsHolder | ||
IsInImportMode bool | ||
IsSovereign bool | ||
ESDTPrefix string | ||
} | ||
|
||
type statusComponentsFactory struct { | ||
|
@@ -64,6 +66,7 @@ type statusComponentsFactory struct { | |
cryptoComponents factory.CryptoComponentsHolder | ||
isInImportMode bool | ||
isSovereign bool | ||
esdtPrefix string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why Pass There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's just the |
||
} | ||
|
||
var log = logger.GetOrCreate("factory") | ||
|
@@ -109,6 +112,7 @@ func NewStatusComponentsFactory(args StatusComponentsFactoryArgs) (*statusCompon | |
isInImportMode: args.IsInImportMode, | ||
cryptoComponents: args.CryptoComponents, | ||
isSovereign: args.IsSovereign, | ||
esdtPrefix: args.ESDTPrefix, | ||
}, nil | ||
} | ||
|
||
|
@@ -218,6 +222,13 @@ func (scf *statusComponentsFactory) createOutportDriver() (outport.OutportHandle | |
|
||
func (scf *statusComponentsFactory) makeElasticIndexerArgs() indexerFactory.ArgsIndexerFactory { | ||
elasticSearchConfig := scf.externalConfig.ElasticSearchConnector | ||
mainChainElastic := esFactory.ElasticConfig{ | ||
Enabled: scf.externalConfig.MainChainElasticSearchConnector.Enabled, | ||
Url: scf.externalConfig.MainChainElasticSearchConnector.URL, | ||
UserName: scf.externalConfig.MainChainElasticSearchConnector.Username, | ||
Password: scf.externalConfig.MainChainElasticSearchConnector.Password, | ||
} | ||
|
||
return indexerFactory.ArgsIndexerFactory{ | ||
Enabled: elasticSearchConfig.Enabled, | ||
BulkRequestMaxSize: elasticSearchConfig.BulkRequestMaxSizeInBytes, | ||
|
@@ -234,6 +245,8 @@ func (scf *statusComponentsFactory) makeElasticIndexerArgs() indexerFactory.Args | |
ImportDB: scf.isInImportMode, | ||
HeaderMarshaller: scf.coreComponents.InternalMarshalizer(), | ||
Sovereign: scf.isSovereign, | ||
ESDTPrefix: scf.esdtPrefix, | ||
MainChainElastic: mainChainElastic, | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ WALLET="~/wallet.pem" | |
WALLET_SOVEREIGN="~/MultiversX/testnet/node/config/walletKey.pem" | ||
|
||
#=========== NETWORK CONFIGURATION =========== | ||
MAIN_CHAIN_ELASTIC=https://testnet-index.multiversx.com | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this config be automatically updated to mainnet/devnet elastic link if we change the script configuration chain ID? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
PROXY=https://testnet-gateway.multiversx.com | ||
CHAIN_ID=T | ||
PROXY_SOVEREIGN=http://localhost:${PORT_PROXY} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import os | ||
import sys | ||
import re | ||
import sys | ||
|
||
|
||
def update_subscribed_addresses(lines, section, identifier, main_chain_address) -> []: | ||
|
@@ -68,11 +68,37 @@ def update_node_configs(config_path, esdt_prefix, sovereign_chain_address): | |
update_transfer_and_execute_address(config_path + "/config.toml", sovereign_chain_address) | ||
|
||
|
||
def update_main_chain_elastic_url(lines, section, key, value): | ||
updated_lines = [] | ||
section_found = False | ||
|
||
for line in lines: | ||
if line.startswith("[" + section + "]"): | ||
section_found = True | ||
if section_found and key in line: | ||
line = re.sub(rf'({re.escape(key)}\s*=\s*)".*?"', rf'\1"{value}"', line) | ||
section_found = False | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why set this to False if you don't use it afterwards? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will skip the second |
||
updated_lines.append(line) | ||
|
||
return updated_lines | ||
|
||
|
||
def update_external_config(file_path, main_chain_elastic): | ||
with open(file_path, 'r') as file: | ||
lines = file.readlines() | ||
|
||
updated_lines = update_main_chain_elastic_url(lines, "MainChainElasticSearchConnector", "URL", main_chain_elastic) | ||
|
||
with open(file_path, 'w') as file: | ||
file.writelines(updated_lines) | ||
|
||
|
||
def main(): | ||
# input arguments | ||
main_chain_address = sys.argv[1] | ||
sovereign_chain_address = sys.argv[2] | ||
esdt_prefix = sys.argv[3] | ||
main_chain_elastic = sys.argv[4] | ||
|
||
current_path = os.getcwd() | ||
project = 'mx-chain-go' | ||
|
@@ -84,6 +110,9 @@ def main(): | |
config_path = project_path + "/cmd/node/config" | ||
update_node_configs(config_path, esdt_prefix, sovereign_chain_address) | ||
|
||
external_path = project_path + "/cmd/node/config/external.toml" | ||
update_external_config(external_path, main_chain_elastic) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you give an example here in the comment with a link to the public es link from our mainnet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not put it here, I don't think is necessary. The deploy scripts update this automatically