-
-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use block state slot to get fork type (#2440)
* Use block and state slot to get ForkName and type * Update consumers * Update tests
- Loading branch information
Showing
26 changed files
with
269 additions
and
610 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import {IBeaconConfig} from "@chainsafe/lodestar-config"; | ||
import {Bucket, IDatabaseController, Repository} from "@chainsafe/lodestar-db"; | ||
import {allForks} from "@chainsafe/lodestar-types"; | ||
import {getBlockTypeFromBlock, getBlockTypeFromBytes} from "./utils/multifork"; | ||
|
||
/** | ||
* Blocks by root | ||
* | ||
* Used to store unfinalized blocks | ||
*/ | ||
export class BlockRepository extends Repository<Uint8Array, allForks.SignedBeaconBlock> { | ||
constructor(config: IBeaconConfig, db: IDatabaseController<Buffer, Buffer>) { | ||
const type = config.types.phase0.SignedBeaconBlock; // Pick some type but won't be used | ||
super(config, db, Bucket.allForks_block, type); | ||
} | ||
|
||
/** | ||
* Id is hashTreeRoot of unsigned BeaconBlock | ||
*/ | ||
getId(value: allForks.SignedBeaconBlock): Uint8Array { | ||
return getBlockTypeFromBlock(this.config, value).fields["message"].hashTreeRoot(value.message); | ||
} | ||
|
||
encodeValue(value: allForks.SignedBeaconBlock): Buffer { | ||
return getBlockTypeFromBlock(this.config, value).serialize(value) as Buffer; | ||
} | ||
|
||
decodeValue(data: Buffer): allForks.SignedBeaconBlock { | ||
return getBlockTypeFromBytes(this.config, data).deserialize(data); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.