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
2bd377a3
Commit
2bd377a3
authored
May 20, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed transaction hash for poc 5
parent
7d3e99a2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
38 deletions
+57
-38
block.go
ethchain/block.go
+40
-36
block_chain.go
ethchain/block_chain.go
+16
-0
genesis.go
ethchain/genesis.go
+1
-2
No files found.
ethchain/block.go
View file @
2bd377a3
...
@@ -4,6 +4,7 @@ import (
...
@@ -4,6 +4,7 @@ import (
"fmt"
"fmt"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethutil"
"math/big"
"math/big"
"strconv"
"time"
"time"
)
)
...
@@ -214,7 +215,12 @@ func (block *Block) SetUncles(uncles []*Block) {
...
@@ -214,7 +215,12 @@ func (block *Block) SetUncles(uncles []*Block) {
func
(
block
*
Block
)
SetTransactions
(
txs
[]
*
Transaction
)
{
func
(
block
*
Block
)
SetTransactions
(
txs
[]
*
Transaction
)
{
block
.
transactions
=
txs
block
.
transactions
=
txs
block
.
TxSha
=
ethutil
.
Sha3Bin
(
ethutil
.
Encode
(
block
.
rlpTxs
()))
trie
:=
ethutil
.
NewTrie
(
ethutil
.
Config
.
Db
,
""
)
for
i
,
tx
:=
range
txs
{
trie
.
Update
(
strconv
.
Itoa
(
i
),
string
(
tx
.
RlpEncode
()))
}
block
.
TxSha
=
trie
.
Root
.
([]
byte
)
}
}
func
(
block
*
Block
)
Value
()
*
ethutil
.
Value
{
func
(
block
*
Block
)
Value
()
*
ethutil
.
Value
{
...
@@ -293,45 +299,10 @@ func NewUncleBlockFromValue(header *ethutil.Value) *Block {
...
@@ -293,45 +299,10 @@ func NewUncleBlockFromValue(header *ethutil.Value) *Block {
return
block
return
block
}
}
func
(
block
*
Block
)
String
()
string
{
//return fmt.Sprintf("Block(%x):\nPrevHash:%x\nUncleSha:%x\nCoinbase:%x\nRoot:%x\nTxSha:%x\nDiff:%v\nNonce:%x\nTxs:%d\n", block.Hash(), block.PrevHash, block.UncleSha, block.Coinbase, block.state.trie.Root, block.TxSha, block.Difficulty, block.Time, block.Nonce, len(block.transactions))
return
fmt
.
Sprintf
(
`
Block(%x):
PrevHash: %x
UncleSha: %x
Coinbase: %x
Root: %x
TxSha: %x
Difficulty: %v
Number: %v
MinGas: %v
MaxLimit: %v
GasUsed: %v
Time: %v
Extra: %v
Nonce: %x
`
,
block
.
Hash
(),
block
.
PrevHash
,
block
.
UncleSha
,
block
.
Coinbase
,
block
.
state
.
trie
.
Root
,
block
.
TxSha
,
block
.
Difficulty
,
block
.
Number
,
block
.
MinGasPrice
,
block
.
GasLimit
,
block
.
GasUsed
,
block
.
Time
,
block
.
Extra
,
block
.
Nonce
)
}
func
(
block
*
Block
)
GetRoot
()
interface
{}
{
func
(
block
*
Block
)
GetRoot
()
interface
{}
{
return
block
.
state
.
trie
.
Root
return
block
.
state
.
trie
.
Root
}
}
//////////// UNEXPORTED /////////////////
func
(
block
*
Block
)
header
()
[]
interface
{}
{
func
(
block
*
Block
)
header
()
[]
interface
{}
{
return
[]
interface
{}{
return
[]
interface
{}{
// Sha of the previous block
// Sha of the previous block
...
@@ -362,3 +333,36 @@ func (block *Block) header() []interface{} {
...
@@ -362,3 +333,36 @@ func (block *Block) header() []interface{} {
block
.
Nonce
,
block
.
Nonce
,
}
}
}
}
func
(
block
*
Block
)
String
()
string
{
return
fmt
.
Sprintf
(
`
BLOCK(%x):
PrevHash: %x
UncleSha: %x
Coinbase: %x
Root: %x
TxSha: %x
Difficulty: %v
Number: %v
MinGas: %v
MaxLimit: %v
GasUsed: %v
Time: %v
Extra: %v
Nonce: %x
`
,
block
.
Hash
(),
block
.
PrevHash
,
block
.
UncleSha
,
block
.
Coinbase
,
block
.
state
.
trie
.
Root
,
block
.
TxSha
,
block
.
Difficulty
,
block
.
Number
,
block
.
MinGasPrice
,
block
.
GasLimit
,
block
.
GasUsed
,
block
.
Time
,
block
.
Extra
,
block
.
Nonce
)
}
ethchain/block_chain.go
View file @
2bd377a3
...
@@ -70,6 +70,22 @@ func (bc *BlockChain) NewBlock(coinbase []byte, txs []*Transaction) *Block {
...
@@ -70,6 +70,22 @@ func (bc *BlockChain) NewBlock(coinbase []byte, txs []*Transaction) *Block {
diff
.
Mul
(
diff
,
mul
)
diff
.
Mul
(
diff
,
mul
)
diff
.
Add
(
diff
,
bc
.
CurrentBlock
.
Difficulty
)
diff
.
Add
(
diff
,
bc
.
CurrentBlock
.
Difficulty
)
block
.
Difficulty
=
diff
block
.
Difficulty
=
diff
block
.
Number
=
new
(
big
.
Int
)
.
Add
(
bc
.
CurrentBlock
.
Number
,
ethutil
.
Big1
)
// max(10000, (parent gas limit * (1024 - 1) + (parent gas used * 6 / 5)) / 1024)
base
:=
new
(
big
.
Int
)
base2
:=
new
(
big
.
Int
)
parentGL
:=
bc
.
CurrentBlock
.
GasLimit
parentUsed
:=
bc
.
CurrentBlock
.
GasUsed
base
.
Mul
(
parentGL
,
big
.
NewInt
(
1024
-
1
))
base2
.
Mul
(
parentUsed
,
big
.
NewInt
(
6
))
base2
.
Div
(
base2
,
big
.
NewInt
(
5
))
base
.
Add
(
base
,
base2
)
base
.
Div
(
base
,
big
.
NewInt
(
1024
))
block
.
GasLimit
=
ethutil
.
BigMax
(
big
.
NewInt
(
10000
),
base
)
}
}
return
block
return
block
...
...
ethchain/genesis.go
View file @
2bd377a3
...
@@ -22,9 +22,8 @@ var GenesisHeader = []interface{}{
...
@@ -22,9 +22,8 @@ var GenesisHeader = []interface{}{
ZeroHash160
,
ZeroHash160
,
// Root state
// Root state
""
,
""
,
//
EmptyShaList,
//
tx sha
ZeroHash256
,
ZeroHash256
,
//ethutil.Sha3Bin(ethutil.Encode(ZeroHash256)),
// Difficulty
// Difficulty
ethutil
.
BigPow
(
2
,
22
),
ethutil
.
BigPow
(
2
,
22
),
// Number
// Number
...
...
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