예제 #1
0
        public LinkBuilder WithRefs(LinkReference[] refs)
        {
            if (refs != null)
            {
                for (int i = 0; i < refs.Length; i++)
                {
                    LinkReference @ref = refs[i];
                    if (String.IsNullOrEmpty(@ref.Process))
                    {
                        throw new ChainscriptException(Error.LinkProcessMissing);
                    }

                    if (@ref.LinkHash == null || @ref.LinkHash.Length == 0)
                    {
                        throw new ChainscriptException(Error.LinkHashMissing);
                    }
                    Stratumn.Chainscript.Proto.LinkReference reference = new Proto.LinkReference()
                    {
                        LinkHash = ByteString.CopyFrom(@ref.LinkHash),
                        Process  = @ref.Process
                    };

                    this.link.Meta.Refs.Add(reference);
                }
            }
            return(this);
        }
예제 #2
0
        /// <summary>
        /// A link can contain references to other links. </summary>
        /// <exception cref="ChainscriptException">
        /// @returns referenced links. </exception>
        public LinkReference[] Refs()
        {
            IList <Stratumn.Chainscript.Proto.LinkReference> refList = LinkMeta.Refs;

            if (refList == null)
            {
                return(new LinkReference[0]);
            }

            IList <LinkReference> refListOut = new List <LinkReference>();

            foreach (Stratumn.Chainscript.Proto.LinkReference @ref in refList)
            {
                LinkReference linkReference;
                linkReference = new LinkReference(@ref.LinkHash != null ? @ref.LinkHash.ToByteArray() : new byte[0], @ref.Process ?? "");
                refListOut.Add(linkReference);
            }
            return(refListOut.ToArray());
        }