Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
73d21ea6
Commit
73d21ea6
authored
Dec 16, 2015
by
zsfelfoldi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: create a header chain structure shared by core.BlockChain and light.LightChain
parent
bff9ceb6
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
575 additions
and
345 deletions
+575
-345
blockchain.go
core/blockchain.go
+125
-340
blockchain_test.go
core/blockchain_test.go
+8
-3
headerchain.go
core/headerchain.go
+432
-0
types.go
core/types.go
+10
-2
No files found.
core/blockchain.go
View file @
73d21ea6
This diff is collapsed.
Click to expand it.
core/blockchain_test.go
View file @
73d21ea6
...
@@ -472,11 +472,16 @@ func makeBlockChainWithDiff(genesis *types.Block, d []int, seed byte) []*types.B
...
@@ -472,11 +472,16 @@ func makeBlockChainWithDiff(genesis *types.Block, d []int, seed byte) []*types.B
func
chm
(
genesis
*
types
.
Block
,
db
ethdb
.
Database
)
*
BlockChain
{
func
chm
(
genesis
*
types
.
Block
,
db
ethdb
.
Database
)
*
BlockChain
{
var
eventMux
event
.
TypeMux
var
eventMux
event
.
TypeMux
bc
:=
&
BlockChain
{
chainDb
:
db
,
genesisBlock
:
genesis
,
eventMux
:
&
eventMux
,
pow
:
FakePow
{},
rand
:
rand
.
New
(
rand
.
NewSource
(
0
))}
bc
:=
&
BlockChain
{
bc
.
headerCache
,
_
=
lru
.
New
(
100
)
chainDb
:
db
,
genesisBlock
:
genesis
,
eventMux
:
&
eventMux
,
pow
:
FakePow
{},
}
valFn
:=
func
()
HeaderValidator
{
return
bc
.
Validator
()
}
bc
.
hc
,
_
=
NewHeaderChain
(
db
,
valFn
,
bc
.
getProcInterrupt
)
bc
.
bodyCache
,
_
=
lru
.
New
(
100
)
bc
.
bodyCache
,
_
=
lru
.
New
(
100
)
bc
.
bodyRLPCache
,
_
=
lru
.
New
(
100
)
bc
.
bodyRLPCache
,
_
=
lru
.
New
(
100
)
bc
.
tdCache
,
_
=
lru
.
New
(
100
)
bc
.
blockCache
,
_
=
lru
.
New
(
100
)
bc
.
blockCache
,
_
=
lru
.
New
(
100
)
bc
.
futureBlocks
,
_
=
lru
.
New
(
100
)
bc
.
futureBlocks
,
_
=
lru
.
New
(
100
)
bc
.
SetValidator
(
bproc
{})
bc
.
SetValidator
(
bproc
{})
...
...
core/headerchain.go
0 → 100644
View file @
73d21ea6
This diff is collapsed.
Click to expand it.
core/types.go
View file @
73d21ea6
...
@@ -38,14 +38,22 @@ import (
...
@@ -38,14 +38,22 @@ import (
// ValidateHeader validates the given header and parent and returns an error
// ValidateHeader validates the given header and parent and returns an error
// if it failed to do so.
// if it failed to do so.
//
//
// ValidateSta
ck
validates the given statedb and optionally the receipts and
// ValidateSta
te
validates the given statedb and optionally the receipts and
// gas used. The implementor should decide what to do with the given input.
// gas used. The implementor should decide what to do with the given input.
type
Validator
interface
{
type
Validator
interface
{
HeaderValidator
ValidateBlock
(
block
*
types
.
Block
)
error
ValidateBlock
(
block
*
types
.
Block
)
error
ValidateHeader
(
header
,
parent
*
types
.
Header
,
checkPow
bool
)
error
ValidateState
(
block
,
parent
*
types
.
Block
,
state
*
state
.
StateDB
,
receipts
types
.
Receipts
,
usedGas
*
big
.
Int
)
error
ValidateState
(
block
,
parent
*
types
.
Block
,
state
*
state
.
StateDB
,
receipts
types
.
Receipts
,
usedGas
*
big
.
Int
)
error
}
}
// HeaderValidator is an interface for validating headers only
//
// ValidateHeader validates the given header and parent and returns an error
// if it failed to do so.
type
HeaderValidator
interface
{
ValidateHeader
(
header
,
parent
*
types
.
Header
,
checkPow
bool
)
error
}
// Processor is an interface for processing blocks using a given initial state.
// Processor is an interface for processing blocks using a given initial state.
//
//
// Process takes the block to be processed and the statedb upon which the
// Process takes the block to be processed and the statedb upon which the
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment