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
bd48690f
Commit
bd48690f
authored
May 19, 2014
by
Jeffrey Wilcke
Browse files
Options
Downloads
Patches
Plain Diff
Testing different mining state
parent
8730dfdc
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
ethchain/dagger.go
+2
-2
2 additions, 2 deletions
ethchain/dagger.go
ethchain/transaction_pool.go
+1
-1
1 addition, 1 deletion
ethchain/transaction_pool.go
ethminer/miner.go
+9
-10
9 additions, 10 deletions
ethminer/miner.go
with
12 additions
and
13 deletions
ethchain/dagger.go
+
2
−
2
View file @
bd48690f
...
@@ -29,14 +29,14 @@ func (pow *EasyPow) Search(block *Block, reactChan chan ethutil.React) []byte {
...
@@ -29,14 +29,14 @@ func (pow *EasyPow) Search(block *Block, reactChan chan ethutil.React) []byte {
for
{
for
{
select
{
select
{
case
<-
reactChan
:
case
<-
reactChan
:
log
.
Print
ln
(
"[POW] Received reactor event; breaking out."
)
ethutil
.
Config
.
Log
.
Info
ln
(
"[POW] Received reactor event; breaking out."
)
return
nil
return
nil
default
:
default
:
i
++
i
++
if
i
%
1234567
==
0
{
if
i
%
1234567
==
0
{
elapsed
:=
time
.
Now
()
.
UnixNano
()
-
start
elapsed
:=
time
.
Now
()
.
UnixNano
()
-
start
hashes
:=
((
float64
(
1e9
)
/
float64
(
elapsed
))
*
float64
(
i
))
/
1000
hashes
:=
((
float64
(
1e9
)
/
float64
(
elapsed
))
*
float64
(
i
))
/
1000
log
.
Print
ln
(
"[POW] Hashing @"
,
int64
(
hashes
),
"khash"
)
ethutil
.
Config
.
Log
.
Info
ln
(
"[POW] Hashing @"
,
int64
(
hashes
),
"khash"
)
}
}
sha
:=
ethutil
.
Sha3Bin
(
big
.
NewInt
(
r
.
Int63
())
.
Bytes
())
sha
:=
ethutil
.
Sha3Bin
(
big
.
NewInt
(
r
.
Int63
())
.
Bytes
())
...
...
This diff is collapsed.
Click to expand it.
ethchain/transaction_pool.go
+
1
−
1
View file @
bd48690f
...
@@ -131,7 +131,7 @@ func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block, toContract
...
@@ -131,7 +131,7 @@ func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block, toContract
block
.
state
.
UpdateStateObject
(
sender
)
block
.
state
.
UpdateStateObject
(
sender
)
log
.
Print
f
(
"[TXPL] Processed Tx %x
\n
"
,
tx
.
Hash
())
ethutil
.
Config
.
Log
.
Info
f
(
"[TXPL] Processed Tx %x
\n
"
,
tx
.
Hash
())
// Notify all subscribers
// Notify all subscribers
pool
.
Ethereum
.
Reactor
()
.
Post
(
"newTx:post"
,
tx
)
pool
.
Ethereum
.
Reactor
()
.
Post
(
"newTx:post"
,
tx
)
...
...
This diff is collapsed.
Click to expand it.
ethminer/miner.go
+
9
−
10
View file @
bd48690f
...
@@ -5,7 +5,6 @@ import (
...
@@ -5,7 +5,6 @@ import (
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethwire"
"github.com/ethereum/eth-go/ethwire"
"log"
)
)
type
Miner
struct
{
type
Miner
struct
{
...
@@ -61,10 +60,10 @@ func (miner *Miner) listener() {
...
@@ -61,10 +60,10 @@ func (miner *Miner) listener() {
select
{
select
{
case
chanMessage
:=
<-
miner
.
reactChan
:
case
chanMessage
:=
<-
miner
.
reactChan
:
if
block
,
ok
:=
chanMessage
.
Resource
.
(
*
ethchain
.
Block
);
ok
{
if
block
,
ok
:=
chanMessage
.
Resource
.
(
*
ethchain
.
Block
);
ok
{
log
.
Print
ln
(
"[MINER] Got new block via Reactor"
)
ethutil
.
Config
.
Log
.
Info
ln
(
"[MINER] Got new block via Reactor"
)
if
bytes
.
Compare
(
miner
.
ethereum
.
BlockChain
()
.
CurrentBlock
.
Hash
(),
block
.
Hash
())
==
0
{
if
bytes
.
Compare
(
miner
.
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
.
Print
ln
(
"[MINER] New top block found resetting state"
)
ethutil
.
Config
.
Log
.
Info
ln
(
"[MINER] New top block found resetting state"
)
// Filter out which Transactions we have that were not in this block
// Filter out which Transactions we have that were not in this block
var
newtxs
[]
*
ethchain
.
Transaction
var
newtxs
[]
*
ethchain
.
Transaction
...
@@ -86,7 +85,7 @@ func (miner *Miner) listener() {
...
@@ -86,7 +85,7 @@ func (miner *Miner) listener() {
}
else
{
}
else
{
if
bytes
.
Compare
(
block
.
PrevHash
,
miner
.
ethereum
.
BlockChain
()
.
CurrentBlock
.
PrevHash
)
==
0
{
if
bytes
.
Compare
(
block
.
PrevHash
,
miner
.
ethereum
.
BlockChain
()
.
CurrentBlock
.
PrevHash
)
==
0
{
log
.
Print
ln
(
"[MINER] Adding uncle block"
)
ethutil
.
Config
.
Log
.
Info
ln
(
"[MINER] Adding uncle block"
)
miner
.
uncles
=
append
(
miner
.
uncles
,
block
)
miner
.
uncles
=
append
(
miner
.
uncles
,
block
)
//miner.ethereum.StateManager().Prepare(miner.block.State(), miner.block.State())
//miner.ethereum.StateManager().Prepare(miner.block.State(), miner.block.State())
}
}
...
@@ -94,7 +93,7 @@ func (miner *Miner) listener() {
...
@@ -94,7 +93,7 @@ func (miner *Miner) listener() {
}
}
if
tx
,
ok
:=
chanMessage
.
Resource
.
(
*
ethchain
.
Transaction
);
ok
{
if
tx
,
ok
:=
chanMessage
.
Resource
.
(
*
ethchain
.
Transaction
);
ok
{
//log.
Print
ln("[MINER] Got new transaction from Reactor", tx)
//log.
Info
ln("[MINER] Got new transaction from Reactor", tx)
found
:=
false
found
:=
false
for
_
,
ctx
:=
range
miner
.
txs
{
for
_
,
ctx
:=
range
miner
.
txs
{
if
found
=
bytes
.
Compare
(
ctx
.
Hash
(),
tx
.
Hash
())
==
0
;
found
{
if
found
=
bytes
.
Compare
(
ctx
.
Hash
(),
tx
.
Hash
())
==
0
;
found
{
...
@@ -103,16 +102,16 @@ func (miner *Miner) listener() {
...
@@ -103,16 +102,16 @@ func (miner *Miner) listener() {
}
}
if
found
==
false
{
if
found
==
false
{
//log.
Print
ln("[MINER] We did not know about this transaction, adding")
//log.
Info
ln("[MINER] We did not know about this transaction, adding")
miner
.
txs
=
append
(
miner
.
txs
,
tx
)
miner
.
txs
=
append
(
miner
.
txs
,
tx
)
miner
.
block
=
miner
.
ethereum
.
BlockChain
()
.
NewBlock
(
miner
.
coinbase
,
miner
.
txs
)
miner
.
block
=
miner
.
ethereum
.
BlockChain
()
.
NewBlock
(
miner
.
coinbase
,
miner
.
txs
)
miner
.
block
.
SetTransactions
(
miner
.
txs
)
miner
.
block
.
SetTransactions
(
miner
.
txs
)
}
else
{
}
else
{
//log.
Print
ln("[MINER] We already had this transaction, ignoring")
//log.
Info
ln("[MINER] We already had this transaction, ignoring")
}
}
}
}
default
:
default
:
log
.
Print
ln
(
"[MINER] Mining on block. Includes"
,
len
(
miner
.
txs
),
"transactions"
)
ethutil
.
Config
.
Log
.
Info
ln
(
"[MINER] Mining on block. Includes"
,
len
(
miner
.
txs
),
"transactions"
)
// Apply uncles
// Apply uncles
if
len
(
miner
.
uncles
)
>
0
{
if
len
(
miner
.
uncles
)
>
0
{
...
@@ -128,12 +127,12 @@ func (miner *Miner) listener() {
...
@@ -128,12 +127,12 @@ func (miner *Miner) listener() {
if
miner
.
block
.
Nonce
!=
nil
{
if
miner
.
block
.
Nonce
!=
nil
{
err
:=
miner
.
ethereum
.
StateManager
()
.
ProcessBlock
(
miner
.
ethereum
.
StateManager
()
.
CurrentState
(),
miner
.
block
,
true
)
err
:=
miner
.
ethereum
.
StateManager
()
.
ProcessBlock
(
miner
.
ethereum
.
StateManager
()
.
CurrentState
(),
miner
.
block
,
true
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Print
ln
(
err
)
ethutil
.
Config
.
Log
.
Info
ln
(
err
)
miner
.
txs
=
[]
*
ethchain
.
Transaction
{}
// Move this somewhere neat
miner
.
txs
=
[]
*
ethchain
.
Transaction
{}
// Move this somewhere neat
miner
.
block
=
miner
.
ethereum
.
BlockChain
()
.
NewBlock
(
miner
.
coinbase
,
miner
.
txs
)
miner
.
block
=
miner
.
ethereum
.
BlockChain
()
.
NewBlock
(
miner
.
coinbase
,
miner
.
txs
)
}
else
{
}
else
{
miner
.
ethereum
.
Broadcast
(
ethwire
.
MsgBlockTy
,
[]
interface
{}{
miner
.
block
.
Value
()
.
Val
})
miner
.
ethereum
.
Broadcast
(
ethwire
.
MsgBlockTy
,
[]
interface
{}{
miner
.
block
.
Value
()
.
Val
})
log
.
Print
f
(
"[MINER] 🔨 Mined block %x
\n
"
,
miner
.
block
.
Hash
())
ethutil
.
Config
.
Log
.
Info
f
(
"[MINER] 🔨 Mined block %x
\n
"
,
miner
.
block
.
Hash
())
miner
.
txs
=
[]
*
ethchain
.
Transaction
{}
// Move this somewhere neat
miner
.
txs
=
[]
*
ethchain
.
Transaction
{}
// Move this somewhere neat
miner
.
block
=
miner
.
ethereum
.
BlockChain
()
.
NewBlock
(
miner
.
coinbase
,
miner
.
txs
)
miner
.
block
=
miner
.
ethereum
.
BlockChain
()
.
NewBlock
(
miner
.
coinbase
,
miner
.
txs
)
...
...
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