Consistency in exposing header hashes (#546)

* Consistency in exposing header hashes

* Cleanup comments
This commit is contained in:
Jaco Greeff
2019-01-08 13:18:09 +01:00
committed by GitHub
parent bc4ada647b
commit 783db16cea
2 changed files with 25 additions and 10 deletions
+17 -10
View File
@@ -30,23 +30,30 @@ export default class Block extends Struct {
}
/**
* @description The [[Extrinsics]] conatined in the block
* @description Encodes a content [[Hash]] for the block
*/
get extrinsics (): Extrinsics {
return this.get('extrinsics') as Extrinsics;
}
/**
* @description Coinvenience getter, encoded the [[Hash]] for the block
*/
get hash (): Hash {
get contentHash (): Hash {
return new Hash(
blake2AsU8a(this.toU8a(), 256)
);
}
/**
* @description The [[Header]] in the block
* @description The [[Extrinsics]] contained in the block
*/
get extrinsics (): Extrinsics {
return this.get('extrinsics') as Extrinsics;
}
/**
* @description Block/header [[Hash]]
*/
get hash (): Hash {
return this.header.hash;
}
/**
* @description The [[Header]] of the block
*/
get header (): Header {
return this.get('header') as Header;
+8
View File
@@ -6,6 +6,7 @@ import { AnyU8a } from './types';
import Struct from './codec/Struct';
import Block, { BlockValue } from './Block';
import Hash from './Hash';
import Justification from './Justification';
type SignedBlockValue = {
@@ -33,6 +34,13 @@ export default class SignedBlock extends Struct {
return this.get('block') as Block;
}
/**
* @description Block/header [[Hash]]
*/
get hash (): Hash {
return this.block.hash;
}
/**
* @description The wrapped [[Justification]]
*/