Skip to content

Commit

Permalink
rename fields; upgrade to AntShares.VM 1.2.1;
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Zhang committed Dec 19, 2016
1 parent c1b16ec commit b7cc047
Show file tree
Hide file tree
Showing 16 changed files with 187 additions and 248 deletions.
2 changes: 1 addition & 1 deletion src/AntShares/Consensus/ConsensusContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public Block MakeHeader()
MerkleRoot = MerkleTree.ComputeRoot(TransactionHashes),
Timestamp = Timestamp,
Height = Height,
Nonce = Nonce,
ConsensusData = Nonce,
NextMiner = NextMiner,
Transactions = new Transaction[0]
};
Expand Down
2 changes: 1 addition & 1 deletion src/AntShares/Core/Block.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public Header Header
MerkleRoot = MerkleRoot,
Timestamp = Timestamp,
Height = Height,
Nonce = Nonce,
ConsensusData = ConsensusData,
NextMiner = NextMiner,
Script = Script
};
Expand Down
18 changes: 10 additions & 8 deletions src/AntShares/Core/BlockBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ public abstract class BlockBase : IApiInterface, ISignable
/// 区块高度
/// </summary>
public uint Height;
/// <summary>
/// 随机数
/// </summary>
public ulong Nonce;
public ulong ConsensusData;
/// <summary>
/// 下一个区块的记账合约的散列值
/// </summary>
Expand Down Expand Up @@ -85,11 +82,11 @@ void ISignable.DeserializeUnsigned(BinaryReader reader)
MerkleRoot = reader.ReadSerializable<UInt256>();
Timestamp = reader.ReadUInt32();
Height = reader.ReadUInt32();
Nonce = reader.ReadUInt64();
ConsensusData = reader.ReadUInt64();
NextMiner = reader.ReadSerializable<UInt160>();
}

byte[] ISignableObject.GetMessage()
byte[] IScriptContainer.GetMessage()
{
return this.GetHashData();
}
Expand All @@ -116,10 +113,15 @@ void ISignable.SerializeUnsigned(BinaryWriter writer)
writer.Write(MerkleRoot);
writer.Write(Timestamp);
writer.Write(Height);
writer.Write(Nonce);
writer.Write(ConsensusData);
writer.Write(NextMiner);
}

byte[] IApiInterface.ToArray()
{
return this.ToArray();
}

public virtual JObject ToJson()
{
JObject json = new JObject();
Expand All @@ -130,7 +132,7 @@ public virtual JObject ToJson()
json["merkleroot"] = MerkleRoot.ToString();
json["time"] = Timestamp;
json["height"] = Height;
json["nonce"] = Nonce.ToString("x16");
json["nonce"] = ConsensusData.ToString("x16");
json["nextminer"] = Wallet.ToAddress(NextMiner);
json["script"] = Script.ToJson();
return json;
Expand Down
2 changes: 1 addition & 1 deletion src/AntShares/Core/Blockchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public abstract class Blockchain : IDisposable, IScriptTable
PrevBlock = UInt256.Zero,
Timestamp = (new DateTime(2016, 7, 15, 15, 8, 21, DateTimeKind.Utc)).ToTimestamp(),
Height = 0,
Nonce = 2083236893, //向比特币致敬
ConsensusData = 2083236893, //向比特币致敬
NextMiner = GetMinerAddress(StandbyMiners),
Script = new Witness
{
Expand Down
5 changes: 5 additions & 0 deletions src/AntShares/Core/CoinReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ void ISerializable.Serialize(BinaryWriter writer)
writer.Write(PrevIndex);
}

byte[] IApiInterface.ToArray()
{
return this.ToArray();
}

/// <summary>
/// 将交易输入转变为json对象
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/AntShares/Core/Header.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace AntShares.Core
{
public class Header : BlockBase, IApiInterface, IEquatable<Header>
public class Header : BlockBase, IEquatable<Header>
{
public override int Size => base.Size + 1;

Expand Down
2 changes: 1 addition & 1 deletion src/AntShares/Core/ISignable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace AntShares.Core
/// <summary>
/// 为需要签名的数据提供一个接口
/// </summary>
public interface ISignable : ISerializable, ISignableObject
public interface ISignable : ISerializable, IScriptContainer
{
/// <summary>
/// 用于验证该对象的脚本列表
Expand Down
2 changes: 1 addition & 1 deletion src/AntShares/Core/Order.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private void DeserializeUnsignedInternal(BinaryReader reader, UInt256 asset_id,
throw new FormatException();
}

byte[] ISignableObject.GetMessage()
byte[] IScriptContainer.GetMessage()
{
return this.GetHashData();
}
Expand Down
7 changes: 6 additions & 1 deletion src/AntShares/Core/Transaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public override int GetHashCode()
return Hash.GetHashCode();
}

byte[] ISignableObject.GetMessage()
byte[] IScriptContainer.GetMessage()
{
return this.GetHashData();
}
Expand Down Expand Up @@ -285,6 +285,11 @@ void ISignable.SerializeUnsigned(BinaryWriter writer)
writer.Write(Outputs);
}

byte[] IApiInterface.ToArray()
{
return this.ToArray();
}

/// <summary>
/// 变成json对象
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions src/AntShares/Core/TransactionAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ void ISerializable.Serialize(BinaryWriter writer)
writer.Write(Data);
}

byte[] IApiInterface.ToArray()
{
return this.ToArray();
}

/// <summary>
/// 变成json对象
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions src/AntShares/Core/TransactionOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ void ISerializable.Serialize(BinaryWriter writer)
writer.Write(ScriptHash);
}

byte[] IApiInterface.ToArray()
{
return this.ToArray();
}

/// <summary>
/// 将交易输出转变为json对象
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/AntShares/Network/Payloads/ConsensusPayload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void ISignable.DeserializeUnsigned(BinaryReader reader)
Data = reader.ReadVarBytes();
}

byte[] ISignableObject.GetMessage()
byte[] IScriptContainer.GetMessage()
{
return this.GetHashData();
}
Expand Down
2 changes: 1 addition & 1 deletion src/AntShares/Network/Payloads/MerkleBlockPayload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static MerkleBlockPayload Create(Block block, BitArray flags)
MerkleRoot = block.MerkleRoot,
Timestamp = block.Timestamp,
Height = block.Height,
Nonce = block.Nonce,
ConsensusData = block.ConsensusData,
NextMiner = block.NextMiner,
Script = block.Script,
TxCount = block.Transactions.Length,
Expand Down
10 changes: 5 additions & 5 deletions src/AntShares/Network/RemoteNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,18 +333,18 @@ private void OnMessageReceived(Message message)
if (message.Payload.Length <= 1024 * 1024)
OnInventoryReceived(Transaction.DeserializeFrom(message.Payload));
break;
case "verack":
case "version":
Disconnect(true);
break;
case "alert":
case "merkleblock":
case "notfound":
case "ping":
case "pong":
case "reject":
//暂时忽略
break;
case "verack":
case "version":
default:
Disconnect(true);
//暂时忽略
break;
}
}
Expand Down
Loading

0 comments on commit b7cc047

Please sign in to comment.