Skip to content

Commit

Permalink
Merge pull request #13 from ultimaweapon/mtp
Browse files Browse the repository at this point in the history
Add MTP support
  • Loading branch information
Panu authored Jun 4, 2019
2 parents 09a77fd + 7307dd7 commit f3e871a
Show file tree
Hide file tree
Showing 18 changed files with 646 additions and 24 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Ztm.Data.Entity.Postgres.Migrations
{
public partial class SupportMtp : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<byte[]>(
name: "MtpHashValue",
table: "Blocks",
nullable: true);

migrationBuilder.AddColumn<int>(
name: "MtpVersion",
table: "Blocks",
nullable: true);

migrationBuilder.AddColumn<byte[]>(
name: "Reserved1",
table: "Blocks",
nullable: true);

migrationBuilder.AddColumn<byte[]>(
name: "Reserved2",
table: "Blocks",
nullable: true);
}

protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "MtpHashValue",
table: "Blocks");

migrationBuilder.DropColumn(
name: "MtpVersion",
table: "Blocks");

migrationBuilder.DropColumn(
name: "Reserved1",
table: "Blocks");

migrationBuilder.DropColumn(
name: "Reserved2",
table: "Blocks");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,19 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.IsRequired()
.HasConversion(new ValueConverter<byte[], byte[]>(v => default(byte[]), v => default(byte[]), new ConverterMappingHints(size: 32)));

b.Property<byte[]>("MtpHashValue")
.HasConversion(new ValueConverter<byte[], byte[]>(v => default(byte[]), v => default(byte[]), new ConverterMappingHints(size: 32)));

b.Property<int?>("MtpVersion");

b.Property<long>("Nonce");

b.Property<byte[]>("Reserved1")
.HasConversion(new ValueConverter<byte[], byte[]>(v => default(byte[]), v => default(byte[]), new ConverterMappingHints(size: 32)));

b.Property<byte[]>("Reserved2")
.HasConversion(new ValueConverter<byte[], byte[]>(v => default(byte[]), v => default(byte[]), new ConverterMappingHints(size: 32)));

b.Property<DateTime>("Time");

b.Property<int>("Version");
Expand Down
4 changes: 4 additions & 0 deletions src/Ztm.Data.Entity/Contexts/Main/Block.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ public Block()
public long Nonce { get; set; }
public DateTime Time { get; set; }
public uint256 MerkleRoot { get; set; }
public int? MtpVersion { get; set; }
public uint256 MtpHashValue { get; set; }
public uint256 Reserved1 { get; set; }
public uint256 Reserved2 { get; set; }

public SortedSet<BlockTransaction> Transactions { get; set; }

Expand Down
4 changes: 4 additions & 0 deletions src/Ztm.Data.Entity/Contexts/MainDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ protected virtual void ConfigureBlock(ModelBuilder modelBuilder)
b.Property(e => e.Nonce).IsRequired();
b.Property(e => e.Time).IsRequired();
b.Property(e => e.MerkleRoot).IsRequired().HasConversion(Converters.UInt256ToBytesConverter);
b.Property(e => e.MtpVersion);
b.Property(e => e.MtpHashValue).HasConversion(Converters.UInt256ToBytesConverter);
b.Property(e => e.Reserved1).HasConversion(Converters.UInt256ToBytesConverter);
b.Property(e => e.Reserved2).HasConversion(Converters.UInt256ToBytesConverter);

b.HasKey(e => e.Height);
b.HasAlternateKey(e => e.Hash);
Expand Down
18 changes: 18 additions & 0 deletions src/Ztm.Zcoin.NBitcoin.Tests/ZcoinBlockTests.cs

Large diffs are not rendered by default.

Loading

0 comments on commit f3e871a

Please sign in to comment.