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

Support for arbitrary data #52

Closed
RiccardoM opened this issue Dec 10, 2019 · 0 comments · Fixed by #59
Closed

Support for arbitrary data #52

RiccardoM opened this issue Dec 10, 2019 · 0 comments · Fixed by #59
Assignees
Labels
kind/new-feature Propose the addition of a new feature that does not yet exist x/posts Post module
Milestone

Comments

@RiccardoM
Copy link
Contributor

RiccardoM commented Dec 10, 2019

Context

As Desmos will be a public chain potentially used by many different applications as their backend storage, we might want to allow such applications to store arbitrary data inside posts.

Some examples can be the following.

  • BigDipper might want to store a reference to the chain-id for which the message has been posted and/or the address of the original poster;
  • applications having a local storage might want to store a locally-generated reference to a post in order to easily update its status when its uploaded to the chain.

Arbitrary data support proposal

In order to solve both issues in one single run, I suggest we implement the support for arbitrary data by adding a new field into the Post type.

For sake of simplicity I recommend we only support String -> String associations, and not any king of value type that might be used inappropriately.

With this, any developer can integrate whatever data he wants into the post itself, without having to add any overhead to the overall post structure.

Storage implementation

In order to implement such feature, we can change how Post objects are made, adding a new map[string]string field:

type Post struct {
    PostID            PostID            `json:"id"`
    ParentID          PostID            `json:"parent_id"`
    Message           string            `json:"message"`
    Created           sdk.Int           `json:"created"`
    LastEdited        sdk.Int           `json:"last_edited"`
    AllowsComments    bool              `json:"allows_comments"`
    ExternalReference string            `json:"external_reference"`
    Owner             sdk.AccAddress    `json:"owner"`

    OptionalData      map[string]string `json:"optional_data"` // Contains any kind of arbitrary data
}

I also think that we might want to move the existing ExternalReference field into such map to make the overall object more simple and having less fields leading thus to a smaller size on disk:

type Post struct {
    PostID            PostID            `json:"id"`
    ParentID          PostID            `json:"parent_id"`
    Message           string            `json:"message"`
    Created           sdk.Int           `json:"created"`
    LastEdited        sdk.Int           `json:"last_edited"`
    AllowsComments    bool              `json:"allows_comments"`
    Owner             sdk.AccAddress    `json:"owner"`

    OptionalData      map[string]string `json:"optional_data"` // Contains any kind of arbitrary data
}
@RiccardoM RiccardoM added x/posts Post module kind/new-feature Propose the addition of a new feature that does not yet exist status/specification This feature is currently in the specification process labels Dec 10, 2019
@RiccardoM RiccardoM added this to the v0.2.0 milestone Dec 16, 2019
@RiccardoM RiccardoM added Status:WIP and removed status/specification This feature is currently in the specification process labels Dec 17, 2019
@RiccardoM RiccardoM self-assigned this Dec 17, 2019
@RiccardoM RiccardoM mentioned this issue Dec 17, 2019
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/new-feature Propose the addition of a new feature that does not yet exist x/posts Post module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant