Skip to content

Conversation

@jfinkhaeuser
Copy link
Contributor

Should be the majority of the DOT registry. Tests are missing at this point; I want to add them as well.

@jfinkhaeuser
Copy link
Contributor Author

So, with the tests added, it'd be great to get some feedback from @mnaamani and @siman :)

@siman siman requested a review from mnaamani March 25, 2019 22:27
@siman
Copy link
Contributor

siman commented Mar 25, 2019

A pull requested should go into the development branch, not master. Please check this PR: #3

@jfinkhaeuser jfinkhaeuser changed the base branch from master to development March 26, 2019 13:06
@jfinkhaeuser
Copy link
Contributor Author

Ok, resolved conflicts and changed everything according to feedback. Looks good, no?

use system::{self, ensure_root};
use crate::traits;

pub trait Trait: system::Trait + MaybeDebug
Copy link
Contributor

Choose a reason for hiding this comment

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

In Rust there is a convention to put opening { on the same line with a preceding code:

Suggested change
pub trait Trait: system::Trait + MaybeDebug
pub trait Trait: system::Trait + MaybeDebug {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm fine with changing that, but you're likely going to see this a lot from me :)

pub enum Event<T> where
<T as Trait>::DataObjectTypeID
{
DataObjectTypeAdded(DataObjectTypeID),
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe Registered instead of Added? Such as a function is register_data_object_type

Suggested change
DataObjectTypeAdded(DataObjectTypeID),
DataObjectTypeRegistered(DataObjectTypeID),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, will change.

{
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;

type DataObjectTypeID: Parameter + Member + SimpleArithmetic + Codec + Default + Copy
Copy link
Contributor

Choose a reason for hiding this comment

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

By following Substrate and our naming convention for IDs, it should be: ID -> Id

Suggested change
type DataObjectTypeID: Parameter + Member + SimpleArithmetic + Codec + Default + Copy
type DataObjectTypeId: Parameter + Member + SimpleArithmetic + Codec + Default + Copy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's a naming convention that I've seen a lot in Java, and it's pretty stupid. ID is not a word, it's an abbreviation, so CamelCasing it makes no sense at all. Still, I will change it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Here is a quote from ID article on Wiki:

ID, Id, id or I.D. may refer to:

  • Identity document, any document used to verify a person's identity
  • Identifier, a symbol which uniquely identifies an object or record

I believe that in our cases (AccounId, MemberId, ProposalId) an Id stands for Identifier (i.e. id_entifier. ID could be considered as an abbreviation only in case if we reffer to I_dentity D_ocument – that is not our case at all.

pub struct DataObjectType<T: Trait>
{
// If the OT is registered, an ID must exist, otherwise it's a new OT.
pub id: Option<T::DataObjectTypeID>,
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest changing id type to just T::DataObjectTypeId and creating an additional struct just for updates:

pub struct DataObjectTypeUpdate<T: Trait> {
  description: Option<Vec<u8>>,
  active: Option<bool>,
}

And in update_* function, update only those fields of stored value that are Some in DataObjectTypeUpdate

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, why? I suppose it may keep transaction sizes down. I suppose that could be worth it, but is that the rationale?

Copy link
Member

Choose a reason for hiding this comment

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

The tx size is certainly a benefit, but I think the rationale behind alex's suggestion is so that you wouldn't have to change the function signature in the future if you introduce new fields to theDataObjectType type. (I don't want to put words in his mouth but that is how I understood it when he recommended the same for the members module update_profile() method)

Copy link
Member

Choose a reason for hiding this comment

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

I actually didn't look at the function signature (i assumed there was one parameter per field).. so my point doesn't actually make sense.

Copy link
Contributor

Choose a reason for hiding this comment

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

Because object's id is used quite often (at least on UI: list stored objects, view details of stored objects, etc.) and having it as an Option will require additional check storedObj.id.isSome ? ...then : else... everywhere. Comparing to update – this operation is rate and exists only on Update Form.

@mnaamani mnaamani merged commit 62f1b9c into Joystream:development Mar 26, 2019
@jfinkhaeuser jfinkhaeuser deleted the data-object-type-registry branch March 27, 2019 09:53
shamil-gadelshin pushed a commit to shamil-gadelshin/joystream-network that referenced this pull request Mar 9, 2020
shamil-gadelshin pushed a commit to shamil-gadelshin/joystream-network that referenced this pull request Mar 9, 2020
mnaamani referenced this pull request in mnaamani/joystream Apr 16, 2020
update Athens Live Milestones
bedeho pushed a commit that referenced this pull request May 29, 2020
mnaamani referenced this pull request in mnaamani/joystream Jun 19, 2020
range headers can't determine the file size. Since we're not streaming
at the moment, we can safely return file sizes.
mnaamani pushed a commit that referenced this pull request Jul 30, 2022
assimilate council genesis config in mocks to fix benchmarks tests
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.

3 participants