示例#1
0
        private void SetupComputer(Smartcontract smart)
        {
            NewestSmartcontract = smart;

            SmartcontractAddress = smart.ReceivingAddress;

            //prebuild transaction:
            OutTrans = new Transaction(smart.SendTo, 0, "");
            OutTrans.AddFee(0);

            ExpressionList = smart.Code.Expressions;

            //create the state variables
            State = new Dictionary <string, ISCType>(smart.Code.Variables);

            //we get all entrys
            for (int i = 0; i < ExpressionList.Count; i++)
            {
                if (ExpressionList[i].ByteCode == 05)
                {
                    EntryRegister.Add(ExpressionList[i].Args1, i);
                }
                if (ExpressionList[i].ByteCode == 28)
                {
                    LabelRegister.Add(ExpressionList[i].Args1, i);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Equality comparer
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            Smartcontract smart = obj as Smartcontract;

            if (smart == null)
            {
                return(false);
            }

            if (!Code.ToFlatString().Equals(smart.Code.ToFlatString()))
            {
                return(false);
            }

            GenerateHash();
            smart.GenerateHash();

            if (Hash.Equals(smart.Hash))
            {
                return(true);
            }
            return(false);
        }
示例#3
0
 /// <summary>
 /// Object which runs a smartcontract
 /// </summary>
 /// <param name="smart">The smartcontract which should be run</param>
 public Computer(Smartcontract smart)
 {
     SetupComputer(smart);
 }