Example #1
0
        /// <summary>
        /// Create an evidence from a protobuf object. </summary>
        /// <param name="e"> protobuf evidence. </param>
        /// <exception cref="ChainscriptException">  </exception>
        public static Evidence FromProto(Stratumn.Chainscript.Proto.Evidence @object)
        {
            string version  = String.IsNullOrEmpty(@object.Version) ? "" : @object.Version;
            string backend  = String.IsNullOrEmpty(@object.Backend) ? "" : @object.Backend;
            string provider = String.IsNullOrEmpty(@object.Provider) ? "" : @object.Provider;

            byte[] proof = @object.Proof != null ? (@object.Proof).ToByteArray() : new byte[0];

            return(new Evidence(version, backend, provider, proof));
        }
Example #2
0
        /// <summary>
        /// The segment can be enriched with evidence that the link was saved
        /// immutably somewhere. </summary>
        /// <param name="e"> evidence. </param>
        /// <exception cref="ChainscriptException">  </exception>
        public virtual void AddEvidence(Evidence e)
        {
            e.Validate();

            if (this.GetEvidence(e.Backend, e.Provider) != null)
            {
                throw new ChainscriptException(Error.DuplicateEvidence);
            }

            Stratumn.Chainscript.Proto.Evidence pbEvidence = (new Stratumn.Chainscript.Proto.Evidence());
            pbEvidence.Version  = e.Version;
            pbEvidence.Provider = e.Provider;
            pbEvidence.Backend  = e.Backend;
            pbEvidence.Proof    = ByteString.CopyFrom(e.Proof);
            this.pbSegment.Meta.Evidences.Add(pbEvidence);
        }