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

RootMultiStore should reject duplicate storekey name when mount #2038

Closed
mossid opened this issue Aug 15, 2018 · 1 comment
Closed

RootMultiStore should reject duplicate storekey name when mount #2038

mossid opened this issue Aug 15, 2018 · 1 comment
Labels

Comments

@mossid
Copy link
Contributor

mossid commented Aug 15, 2018

It is possible to mount multiple storekeys with same name on RootMultiStore. We should check if the new storekey has unique name before we mount it.

Before:

//...
        if _, ok := rs.storesParams[key]; ok {
		panic(fmt.Sprintf("rootMultiStore duplicate store key %v", key))
	}
	rs.storesParams[key] = storeParams{
		key: key,
		typ: typ,
		db:  db,
	}
	rs.keysByName[key.Name()] = key
//...

After:

        if _, ok := rs.storesParams[key]; ok {
		panic(fmt.Sprintf("rootMultiStore duplicate store key %v", key))
	}
        for k := range rs.storeParams {
                if k.Name() == key.Name() {
                        panic(fmt.Sprintf("rootMultiStore duplicate store key name %v", key))
                }
        }
	rs.storesParams[key] = storeParams{
		key: key,
		typ: typ,
		db:  db,
	}
	rs.keysByName[key.Name()] = key

Also see: #2037

@mossid mossid added the core label Aug 15, 2018
@mossid mossid changed the title RootMultiStore should reject duplicate storekey when mount RootMultiStore should reject duplicate storekey name when mount Aug 15, 2018
@alexanderbez
Copy link
Contributor

Indeed @mossid. I would consider this a bug, but trivial to fix and test! Thanks 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants