Ejemplo n.º 1
0
        public void SetMetadata(object value)
        {
            this.VerifyCompatibility();

            switch (this.Version())
            {
            case Constants.LINK_VERSION_1_0_0:
                try
                {
                    string canonicalData = Canonicalizer.Stringify(value);
                    LinkMeta.Data = ByteString.CopyFrom(Encoding.UTF8.GetBytes(canonicalData));

                    Proto.LinkMeta meta = LinkMeta;
                    this.ALink.Meta = meta;
                    return;
                }
                catch (Exception e)
                {
                    throw new ChainscriptException(e);
                }

            default:
                throw new ChainscriptException(Error.LinkVersionUnknown);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Validate checks for errors in a link. </summary>
        /// <exception cref="ChainscriptException">  </exception>
        public void Validate()
        {
            if (string.IsNullOrEmpty(this.ALink.Version))
            {
                throw new ChainscriptException(Error.LinkVersionMissing);
            }

            Proto.LinkMeta meta = LinkMeta;

            if (string.IsNullOrEmpty(meta.MapId))
            {
                throw new ChainscriptException(Error.LinkMapIdMissing);
            }

            if (meta.Process == null || string.IsNullOrEmpty(meta.Process.Name))
            {
                throw new ChainscriptException(Error.LinkProcessMissing);
            }

            this.VerifyCompatibility();
            foreach (LinkReference @ref in this.Refs())
            {
                if (string.IsNullOrEmpty(@ref.Process))
                {
                    throw new ChainscriptException(Error.LinkProcessMissing);
                }
                if (@ref.LinkHash == null || @ref.LinkHash.Length == 0)
                {
                    throw new ChainscriptException(Error.LinkHashMissing);
                }
            }

            foreach (Signature sig in this.Signatures())
            {
                sig.Validate(this);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// A link always belongs to a specific process map. </summary>
 /// <exception cref="Exception">
 /// @returns the link's map id. </exception>
 public string MapId()
 {
     Proto.LinkMeta meta = LinkMeta;
     return(string.IsNullOrEmpty(meta.MapId) ? "" : meta.MapId);
 }