elenadimitrova / ContractFactory

Blog code samples
14 stars 11 forks source link

Need more comment #6

Closed katopz closed 6 years ago

katopz commented 6 years ago

Hi, Can you add more comment each line in this function please?

I'm not quite understand why we kill organisationNew there. To perform upgrade, we should kill old one and replace/refer to new one isn't it? (Yes I'm confusing maybe it's just naming)

  function upgradeOrganisation(bytes32 key_)
  {
    // Refer to old address
    address organisationAddress = organisations[key_];

    // Here's is old organisation
    var organisation = Organisation(organisationAddress);
    var tokenLedger = organisation.tokenLedger();
    var eternalStorage = organisation.eternalStorage();

    // Define new organisation
    OrganisationUpdated organisationNew = new OrganisationUpdated(tokenLedger, eternalStorage);

    // Kill that new organisation? (I don't get this line)
    organisation.kill(organisationNew);

    // Point to killed organisation?
    organisations[key_] = organisationNew;

    // Then upgrade killed organisation?
    OrganisationUpgraded(organisationNew, now);
  }

Thanks!

cristicmf commented 6 years ago

Maybe you can get inspiration from here

cristicmf commented 6 years ago

and the blog @katopz

katopz commented 6 years ago

Oh I got it, it seem like transferAndkill to me instead of just kill, Thanks