예제 #1
0
 public Op Read()
 {
     var b = Inner.ReadByte();
     if(b == -1)
         return null;
     var opcode = (OpcodeType)b;
     if(Op.IsPushCode(opcode))
     {
         Op op = new Op();
         op.Code = opcode;
         op.PushData = op.ReadData(Inner);
         return op;
     }
     return new Op()
     {
         Code = opcode
     };
 }
예제 #2
0
 public static Op GetPushOp(byte[] data)
 {
     Op op = new Op();
     op.PushData = data;
     if(data.Length == 0)
         op.Code = OpcodeType.OP_0;
     else if(data.Length == 1 && (byte)1 <= data[0] && data[0] <= (byte)16)
         op.Code = (OpcodeType)(data[0] + (byte)OpcodeType.OP_1 - 1);
     else if(data.Length == 1 && (byte)0x81 == data[0])
         op.Code = OpcodeType.OP_1NEGATE;
     else if(0x01 <= data.Length && data.Length <= 0x4b)
         op.Code = (OpcodeType)(byte)data.Length;
     else if(data.Length <= 0xFF)
         op.Code = OpcodeType.OP_PUSHDATA1;
     else if(data.Length <= 0xFFFF)
         op.Code = OpcodeType.OP_PUSHDATA2;
     else
         throw new NotSupportedException("Data length should not be bigger than 0xFFFFFFFF");
     return op;
 }
예제 #3
0
 internal int FindAndDelete(Op op)
 {
     return op == null ? 0 : FindAndDelete(o => o.Code == op.Code && o.PushData.SequenceEqual(op.PushData));
 }