good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
54bce64e
Commit
54bce64e
authored
Jan 12, 2014
by
Jeffrey Wilcke
Browse files
Options
Downloads
Patches
Plain Diff
Validations reordering & added nonce validation
parent
bee05d52
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
block_manager.go
+18
-14
18 additions, 14 deletions
block_manager.go
with
18 additions
and
14 deletions
block_manager.go
+
18
−
14
View file @
54bce64e
...
@@ -114,15 +114,18 @@ func (bm *BlockManager) CalculateTD(block *ethutil.Block) bool {
...
@@ -114,15 +114,18 @@ func (bm *BlockManager) CalculateTD(block *ethutil.Block) bool {
}
}
// Validates the current block. Returns an error if the block was invalid,
// Validates the current block. Returns an error if the block was invalid,
// an uncle or anything that isn't on the current block chain
// an uncle or anything that isn't on the current block chain.
// Validation validates easy over difficult (dagger takes longer time = difficult)
func
(
bm
*
BlockManager
)
ValidateBlock
(
block
*
ethutil
.
Block
)
error
{
func
(
bm
*
BlockManager
)
ValidateBlock
(
block
*
ethutil
.
Block
)
error
{
// TODO
// TODO
// 1. Check if the nonce of the block is valid
// 2. Check if the difficulty is correct
// 2. Check if the difficulty is correct
// Check if we have the parent hash, if it isn't known we discard it
// Check if we have the parent hash, if it isn't known we discard it
// Reasons might be catching up or simply an invalid block
// Reasons might be catching up or simply an invalid block
if
bm
.
bc
.
HasBlock
(
block
.
PrevHash
)
{
if
!
bm
.
bc
.
HasBlock
(
block
.
PrevHash
)
{
return
errors
.
New
(
"Block's parent unknown"
)
}
// Check each uncle's previous hash. In order for it to be valid
// Check each uncle's previous hash. In order for it to be valid
// is if it has the same block hash as the current
// is if it has the same block hash as the current
for
_
,
uncle
:=
range
block
.
Uncles
{
for
_
,
uncle
:=
range
block
.
Uncles
{
...
@@ -134,10 +137,11 @@ func (bm *BlockManager) ValidateBlock(block *ethutil.Block) error {
...
@@ -134,10 +137,11 @@ func (bm *BlockManager) ValidateBlock(block *ethutil.Block) error {
return
errors
.
New
(
"Mismatching Prvhash from uncle"
)
return
errors
.
New
(
"Mismatching Prvhash from uncle"
)
}
}
}
}
}
else
{
return
errors
.
New
(
"Block's parent unknown"
)
}
// Verify the nonce of the block. Return an error if it's not valid
if
!
DaggerVerify
(
block
.
Hash
(),
block
.
Nonce
)
{
return
errors
.
New
(
"Block's nonce is invalid"
)
}
return
nil
return
nil
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment