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