Skip to content

Commit

Permalink
add total_kernel_offset
Browse files Browse the repository at this point in the history
  • Loading branch information
hendi committed Apr 19, 2018
1 parent 3f27a02 commit af693df
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def fetch_and_store_block(self, hash, parent_hash):
# we can't set the `previous` PK now because it doesn't exist yet. We'll
# set it in the next call of this function, when the previous Block is saved
previous = block_data["header"].pop("previous")

block = Block.objects.create(
previous=None,
**block_data["header"],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 2.0 on 2018-04-19 10:32

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('blockchain', '0004_remove_block_difficulty'),
]

operations = [
migrations.AddField(
model_name='block',
name='total_kernel_offset',
field=models.CharField(default='', max_length=64),
preserve_default=False,
),
]
2 changes: 2 additions & 0 deletions grinexplorer/blockchain/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class Block(models.Model):
# sum of the target difficulties, not the sum of the actual block difficulties
total_difficulty = models.IntegerField()

total_kernel_offset = models.CharField(max_length=64)

@property
def difficulty(self):
return 0xffffffffffffffff // int(self.hash[:16], 16)
Expand Down
4 changes: 4 additions & 0 deletions grinexplorer/explorer/templates/explorer/block_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ <h2>Block {{ blk.height }}</h2>
<td>Expected Total Difficulty</td>
<td>{{ blk.total_difficulty | intcomma }}</td>
</tr>
<tr>
<td>Total Kernel Offset</td>
<td>{{ blk.total_kernel_offset }}</td>
</tr>
<tr>
<td>Block Reward</td>
<td>{{ blk.reward | grin }}</td>
Expand Down

0 comments on commit af693df

Please sign in to comment.