48 lines
967 B
C#
48 lines
967 B
C#
using System;
|
|
using System.Text;
|
|
using System.IO;
|
|
using sharp.cryptonote.streams;
|
|
using sharp.extensions;
|
|
namespace sharp.cryptonote
|
|
{
|
|
public class Block
|
|
{
|
|
Int64 major_version, minor_version, timestamp;
|
|
byte[] hash;
|
|
UInt32 nonce;
|
|
|
|
|
|
public Block(byte[] buffer)
|
|
{
|
|
decode( new ExtendedStreamReader(new MemoryStream(buffer) ) );
|
|
}
|
|
|
|
private void decode(ExtendedStreamReader reader){
|
|
major_version = reader.readVarInt();
|
|
minor_version = reader.readVarInt();
|
|
timestamp = reader.readVarInt();
|
|
hash = reader.readBytes(32);
|
|
nonce = reader.readUInt32();
|
|
}
|
|
|
|
|
|
|
|
|
|
public byte[] toBytes(){
|
|
return null;
|
|
}
|
|
|
|
|
|
public override string ToString()
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.AppendFormat("[CryptoNote Block] Version: {0}.{1}, TS: {2} NONCE: {3}\n",major_version,minor_version,timestamp,nonce);
|
|
sb.AppendFormat("[CryptoNote Block] Last Blocks Hash: {0}\n",hash.toHexString());
|
|
|
|
return sb.ToString();
|
|
}
|
|
|
|
|
|
}
|
|
}
|