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

Add NetworkByChainID function to return network and blockchain for registered ChainID #460

Merged
merged 2 commits into from
Feb 1, 2024

Conversation

olomix
Copy link
Contributor

@olomix olomix commented Jan 29, 2024

No description provided.

if _, ok := chainIDs[k]; !ok {
return 0, fmt.Errorf("chainID not registered for %s:%s", blockchain, network)
return 0, fmt.Errorf("%w for %s:%s", ErrChainIDNotRegistered, blockchain,
Copy link
Contributor

Choose a reason for hiding this comment

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

Retrun NoChain constant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

NoChain has a Blockchain type, not ChainID.


var ErrChainIDNotRegistered = errors.New("chainID is not registered")

var chainIDsLock sync.RWMutex
Copy link
Contributor

Choose a reason for hiding this comment

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

@olomix Do we really need sync.RWMutex here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What other options do we have to guard concurrent access to global dict?
We can use sync.Map. But typed map with lock I like more.

@vmidyllic vmidyllic merged commit 56c19c5 into master Feb 1, 2024
6 checks passed
@vmidyllic vmidyllic deleted the network_by_chainid branch February 1, 2024 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants