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
9f42835a
Commit
9f42835a
authored
Jan 08, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP Block chain
parent
83bb4a3f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
10 deletions
+24
-10
block_manager.go
block_manager.go
+24
-10
No files found.
block_manager.go
View file @
9f42835a
// Blocks, blocks will have transactions.
// Transactions/contracts are updated in goroutines
// Each contract should send a message on a channel with usage statistics
// The statics can be used for fee calculation within the block update method
// Statistics{transaction, /* integers */ normal_ops, store_load, extro_balance, crypto, steps}
// The block updater will wait for all goroutines to be finished and update the block accordingly
// in one go and should use minimal IO overhead.
// The actual block updating will happen within a goroutine as well so normal operation may continue
package
main
import
(
"fmt"
)
type
BlockChain
struct
{
lastBlock
*
Block
genesisBlock
*
Block
}
func
NewBlockChain
()
*
BlockChain
{
bc
:=
&
BlockChain
{}
bc
.
genesisBlock
=
NewBlock
(
Encode
(
Genesis
)
)
return
bc
}
type
BlockManager
struct
{
vm
*
Vm
blockChain
*
BlockChain
}
func
NewBlockManager
()
*
BlockManager
{
...
...
@@ -26,6 +31,11 @@ func NewBlockManager() *BlockManager {
// Process a block.
func
(
bm
*
BlockManager
)
ProcessBlock
(
block
*
Block
)
error
{
// TODO Validation (Or move to other part of the application)
if
err
:=
bm
.
ValidateBlock
(
block
);
err
!=
nil
{
return
err
}
// Get the tx count. Used to create enough channels to 'join' the go routines
txCount
:=
len
(
block
.
transactions
)
// Locking channel. When it has been fully buffered this method will return
...
...
@@ -50,6 +60,10 @@ func (bm *BlockManager) ProcessBlock(block *Block) error {
return
nil
}
func
(
bm
*
BlockManager
)
ValidateBlock
(
block
*
Block
)
error
{
return
nil
}
func
(
bm
*
BlockManager
)
ProcessContract
(
tx
*
Transaction
,
block
*
Block
,
lockChan
chan
bool
)
{
// Recovering function in case the VM had any errors
defer
func
()
{
...
...
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