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
1c983ed8
Commit
1c983ed8
authored
Mar 11, 2014
by
Maran Hidskes
Browse files
Options
Downloads
Patches
Plain Diff
More mining stuff
parent
96fcc1da
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
ethereum.go
+11
-5
11 additions, 5 deletions
ethereum.go
ui/library.go
+1
-0
1 addition, 0 deletions
ui/library.go
with
12 additions
and
5 deletions
ethereum.go
+
11
−
5
View file @
1c983ed8
...
@@ -173,11 +173,11 @@ func main() {
...
@@ -173,11 +173,11 @@ func main() {
RegisterInterupts
(
ethereum
)
RegisterInterupts
(
ethereum
)
ethereum
.
Start
()
ethereum
.
Start
()
minerChan
:=
make
(
chan
ethutil
.
React
,
5
)
minerChan
:=
make
(
chan
ethutil
.
React
,
1
)
ethereum
.
Reactor
()
.
Subscribe
(
"newBlock"
,
minerChan
)
ethereum
.
Reactor
()
.
Subscribe
(
"newBlock"
,
minerChan
)
ethereum
.
Reactor
()
.
Subscribe
(
"newTx"
,
minerChan
)
ethereum
.
Reactor
()
.
Subscribe
(
"newTx"
,
minerChan
)
minerChan2
:=
make
(
chan
ethutil
.
React
,
5
)
minerChan2
:=
make
(
chan
ethutil
.
React
,
1
)
ethereum
.
Reactor
()
.
Subscribe
(
"newBlock"
,
minerChan2
)
ethereum
.
Reactor
()
.
Subscribe
(
"newBlock"
,
minerChan2
)
ethereum
.
Reactor
()
.
Subscribe
(
"newTx"
,
minerChan2
)
ethereum
.
Reactor
()
.
Subscribe
(
"newTx"
,
minerChan2
)
...
@@ -186,7 +186,6 @@ func main() {
...
@@ -186,7 +186,6 @@ func main() {
if
StartMining
{
if
StartMining
{
log
.
Printf
(
"Miner started
\n
"
)
log
.
Printf
(
"Miner started
\n
"
)
// Fake block mining. It broadcasts a new block every 5 seconds
go
func
()
{
go
func
()
{
pow
:=
&
ethchain
.
EasyPow
{}
pow
:=
&
ethchain
.
EasyPow
{}
data
,
_
:=
ethutil
.
Config
.
Db
.
Get
([]
byte
(
"KeyRing"
))
data
,
_
:=
ethutil
.
Config
.
Db
.
Get
([]
byte
(
"KeyRing"
))
...
@@ -194,6 +193,7 @@ func main() {
...
@@ -194,6 +193,7 @@ func main() {
addr
:=
keyRing
.
Get
(
1
)
.
Bytes
()
addr
:=
keyRing
.
Get
(
1
)
.
Bytes
()
txs
:=
ethereum
.
TxPool
()
.
Flush
()
txs
:=
ethereum
.
TxPool
()
.
Flush
()
block
:=
ethereum
.
BlockChain
()
.
NewBlock
(
addr
,
txs
)
block
:=
ethereum
.
BlockChain
()
.
NewBlock
(
addr
,
txs
)
var
uncles
[]
*
ethchain
.
Block
for
{
for
{
select
{
select
{
...
@@ -204,6 +204,7 @@ func main() {
...
@@ -204,6 +204,7 @@ func main() {
if
bytes
.
Compare
(
ethereum
.
BlockChain
()
.
CurrentBlock
.
Hash
(),
block
.
Hash
())
==
0
{
if
bytes
.
Compare
(
ethereum
.
BlockChain
()
.
CurrentBlock
.
Hash
(),
block
.
Hash
())
==
0
{
// TODO: Perhaps continue mining to get some uncle rewards
// TODO: Perhaps continue mining to get some uncle rewards
log
.
Println
(
"New top block found resetting state"
)
log
.
Println
(
"New top block found resetting state"
)
// TODO: We probably want to skip this if it's our own block
// Reapplies the latest block to the mining state, thus resetting
// Reapplies the latest block to the mining state, thus resetting
ethereum
.
StateManager
()
.
PrepareMiningState
()
ethereum
.
StateManager
()
.
PrepareMiningState
()
block
=
ethereum
.
BlockChain
()
.
NewBlock
(
addr
,
txs
)
block
=
ethereum
.
BlockChain
()
.
NewBlock
(
addr
,
txs
)
...
@@ -212,6 +213,7 @@ func main() {
...
@@ -212,6 +213,7 @@ func main() {
if
bytes
.
Compare
(
block
.
PrevHash
,
ethereum
.
BlockChain
()
.
CurrentBlock
.
PrevHash
)
==
0
{
if
bytes
.
Compare
(
block
.
PrevHash
,
ethereum
.
BlockChain
()
.
CurrentBlock
.
PrevHash
)
==
0
{
log
.
Println
(
"HELLO UNCLE"
)
log
.
Println
(
"HELLO UNCLE"
)
// TODO: Add uncle to block
// TODO: Add uncle to block
uncles
=
append
(
uncles
,
block
)
}
}
}
}
}
}
...
@@ -227,7 +229,7 @@ func main() {
...
@@ -227,7 +229,7 @@ func main() {
}
}
if
found
==
false
{
if
found
==
false
{
log
.
Println
(
"We did not know about this transaction, adding"
)
log
.
Println
(
"We did not know about this transaction, adding"
)
txs
=
append
(
txs
,
tx
)
txs
=
ethereum
.
TxPool
()
.
Flush
(
)
}
else
{
}
else
{
log
.
Println
(
"We already had this transaction, ignoring"
)
log
.
Println
(
"We already had this transaction, ignoring"
)
}
}
...
@@ -239,6 +241,11 @@ func main() {
...
@@ -239,6 +241,11 @@ func main() {
// Create a new block which we're going to mine
// Create a new block which we're going to mine
log
.
Println
(
"Mining on block. Includes"
,
len
(
txs
),
"transactions"
)
log
.
Println
(
"Mining on block. Includes"
,
len
(
txs
),
"transactions"
)
// Apply uncles
if
len
(
uncles
)
>
0
{
block
.
SetUncles
(
uncles
)
}
// Apply all transactions to the block
// Apply all transactions to the block
ethereum
.
StateManager
()
.
ApplyTransactions
(
block
,
txs
)
ethereum
.
StateManager
()
.
ApplyTransactions
(
block
,
txs
)
ethereum
.
StateManager
()
.
AccumelateRewards
(
block
,
block
)
ethereum
.
StateManager
()
.
AccumelateRewards
(
block
,
block
)
...
@@ -253,7 +260,6 @@ func main() {
...
@@ -253,7 +260,6 @@ func main() {
}
else
{
}
else
{
//log.Println("\n+++++++ MINED BLK +++++++\n", ethereum.BlockChain().CurrentBlock)
//log.Println("\n+++++++ MINED BLK +++++++\n", ethereum.BlockChain().CurrentBlock)
log
.
Printf
(
"🔨 Mined block %x
\n
"
,
block
.
Hash
())
log
.
Printf
(
"🔨 Mined block %x
\n
"
,
block
.
Hash
())
block
=
ethereum
.
BlockChain
()
.
NewBlock
(
addr
,
txs
)
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
ui/library.go
+
1
−
0
View file @
1c983ed8
...
@@ -35,6 +35,7 @@ func (lib *EthLib) CreateTx(receiver, a, data string) string {
...
@@ -35,6 +35,7 @@ func (lib *EthLib) CreateTx(receiver, a, data string) string {
tx
.
Nonce
=
lib
.
stateManager
.
GetAddrState
(
keyRing
.
Get
(
1
)
.
Bytes
())
.
Nonce
tx
.
Nonce
=
lib
.
stateManager
.
GetAddrState
(
keyRing
.
Get
(
1
)
.
Bytes
())
.
Nonce
tx
.
Sign
(
keyRing
.
Get
(
0
)
.
Bytes
())
tx
.
Sign
(
keyRing
.
Get
(
0
)
.
Bytes
())
ethutil
.
Config
.
Log
.
Infof
(
"nonce: %x"
,
tx
.
Nonce
)
lib
.
txPool
.
QueueTransaction
(
tx
)
lib
.
txPool
.
QueueTransaction
(
tx
)
...
...
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