Exemple #1
0
        public void CreateChain(Address creator, string organization, string name, string parentName)
        {
            var Runtime = this;

            Runtime.Expect(Runtime.IsRootChain(), "must be root chain");

            var pow = Runtime.Transaction.Hash.GetDifficulty();

            Runtime.Expect(pow >= (int)ProofOfWork.Minimal, "expected proof of work");

            Runtime.Expect(!string.IsNullOrEmpty(name), "name required");
            Runtime.Expect(!string.IsNullOrEmpty(parentName), "parent chain required");

            Runtime.Expect(Runtime.OrganizationExists(organization), "invalid organization");
            var org = Runtime.GetOrganization(organization);

            Runtime.Expect(org.IsMember(creator), "creator does not belong to organization");

            Runtime.Expect(creator.IsUser, "owner address must be user address");
            Runtime.Expect(Runtime.IsStakeMaster(creator), "needs to be master");
            Runtime.Expect(Runtime.IsWitness(creator), "invalid witness");

            name = name.ToLowerInvariant();
            Runtime.Expect(!name.Equals(parentName, StringComparison.OrdinalIgnoreCase), "same name as parent");

            Nexus.CreateChain(RootStorage, organization, name, parentName);
            Runtime.Notify(EventKind.ChainCreate, creator, name);
        }
Exemple #2
0
 public bool CreateChain(Address owner, string name, string parentChain)
 {
     return(Nexus.CreateChain(this.RootStorage, owner, name, parentChain));
 }