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
9d492b05
Commit
9d492b05
authored
Mar 03, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed Address to Account
parent
bfed1c7c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
23 deletions
+23
-23
address.go
ethchain/address.go
+15
-15
block.go
ethchain/block.go
+1
-1
block_manager.go
ethchain/block_manager.go
+3
-3
state.go
ethchain/state.go
+4
-4
No files found.
ethchain/address.go
View file @
9d492b05
...
@@ -5,31 +5,31 @@ import (
...
@@ -5,31 +5,31 @@ import (
"math/big"
"math/big"
)
)
type
A
ddress
struct
{
type
A
ccount
struct
{
Amount
*
big
.
Int
Amount
*
big
.
Int
Nonce
uint64
Nonce
uint64
}
}
func
NewA
ddress
(
amount
*
big
.
Int
)
*
Address
{
func
NewA
ccount
(
amount
*
big
.
Int
)
*
Account
{
return
&
A
ddress
{
Amount
:
amount
,
Nonce
:
0
}
return
&
A
ccount
{
Amount
:
amount
,
Nonce
:
0
}
}
}
func
NewA
ddressFromData
(
data
[]
byte
)
*
Address
{
func
NewA
ccountFromData
(
data
[]
byte
)
*
Account
{
address
:=
&
A
ddress
{}
address
:=
&
A
ccount
{}
address
.
RlpDecode
(
data
)
address
.
RlpDecode
(
data
)
return
address
return
address
}
}
func
(
a
*
A
ddress
)
AddFee
(
fee
*
big
.
Int
)
{
func
(
a
*
A
ccount
)
AddFee
(
fee
*
big
.
Int
)
{
a
.
Amount
.
Add
(
a
.
Amount
,
fee
)
a
.
Amount
.
Add
(
a
.
Amount
,
fee
)
}
}
func
(
a
*
A
ddress
)
RlpEncode
()
[]
byte
{
func
(
a
*
A
ccount
)
RlpEncode
()
[]
byte
{
return
ethutil
.
Encode
([]
interface
{}{
a
.
Amount
,
a
.
Nonce
})
return
ethutil
.
Encode
([]
interface
{}{
a
.
Amount
,
a
.
Nonce
})
}
}
func
(
a
*
A
ddress
)
RlpDecode
(
data
[]
byte
)
{
func
(
a
*
A
ccount
)
RlpDecode
(
data
[]
byte
)
{
decoder
:=
ethutil
.
NewValueFromBytes
(
data
)
decoder
:=
ethutil
.
NewValueFromBytes
(
data
)
a
.
Amount
=
decoder
.
Get
(
0
)
.
BigInt
()
a
.
Amount
=
decoder
.
Get
(
0
)
.
BigInt
()
...
@@ -37,24 +37,24 @@ func (a *Address) RlpDecode(data []byte) {
...
@@ -37,24 +37,24 @@ func (a *Address) RlpDecode(data []byte) {
}
}
type
AddrStateStore
struct
{
type
AddrStateStore
struct
{
states
map
[
string
]
*
A
ddress
State
states
map
[
string
]
*
A
ccount
State
}
}
func
NewAddrStateStore
()
*
AddrStateStore
{
func
NewAddrStateStore
()
*
AddrStateStore
{
return
&
AddrStateStore
{
states
:
make
(
map
[
string
]
*
A
ddress
State
)}
return
&
AddrStateStore
{
states
:
make
(
map
[
string
]
*
A
ccount
State
)}
}
}
func
(
s
*
AddrStateStore
)
Add
(
addr
[]
byte
,
account
*
A
ddress
)
*
Address
State
{
func
(
s
*
AddrStateStore
)
Add
(
addr
[]
byte
,
account
*
A
ccount
)
*
Account
State
{
state
:=
&
A
ddress
State
{
Nonce
:
account
.
Nonce
,
Account
:
account
}
state
:=
&
A
ccount
State
{
Nonce
:
account
.
Nonce
,
Account
:
account
}
s
.
states
[
string
(
addr
)]
=
state
s
.
states
[
string
(
addr
)]
=
state
return
state
return
state
}
}
func
(
s
*
AddrStateStore
)
Get
(
addr
[]
byte
)
*
A
ddress
State
{
func
(
s
*
AddrStateStore
)
Get
(
addr
[]
byte
)
*
A
ccount
State
{
return
s
.
states
[
string
(
addr
)]
return
s
.
states
[
string
(
addr
)]
}
}
type
A
ddress
State
struct
{
type
A
ccount
State
struct
{
Nonce
uint64
Nonce
uint64
Account
*
A
ddress
Account
*
A
ccount
}
}
ethchain/block.go
View file @
9d492b05
...
@@ -142,7 +142,7 @@ func (block *Block) PayFee(addr []byte, fee *big.Int) bool {
...
@@ -142,7 +142,7 @@ func (block *Block) PayFee(addr []byte, fee *big.Int) bool {
data
:=
block
.
state
.
trie
.
Get
(
string
(
block
.
Coinbase
))
data
:=
block
.
state
.
trie
.
Get
(
string
(
block
.
Coinbase
))
// Get the ether (Coinbase) and add the fee (gief fee to miner)
// Get the ether (Coinbase) and add the fee (gief fee to miner)
ether
:=
NewA
ddress
FromData
([]
byte
(
data
))
ether
:=
NewA
ccount
FromData
([]
byte
(
data
))
base
=
new
(
big
.
Int
)
base
=
new
(
big
.
Int
)
ether
.
Amount
=
base
.
Add
(
ether
.
Amount
,
fee
)
ether
.
Amount
=
base
.
Add
(
ether
.
Amount
,
fee
)
...
...
ethchain/block_manager.go
View file @
9d492b05
...
@@ -85,17 +85,17 @@ func NewBlockManager(speaker PublicSpeaker) *BlockManager {
...
@@ -85,17 +85,17 @@ func NewBlockManager(speaker PublicSpeaker) *BlockManager {
}
}
// Watches any given address and puts it in the address state store
// Watches any given address and puts it in the address state store
func
(
bm
*
BlockManager
)
WatchAddr
(
addr
[]
byte
)
*
A
ddress
State
{
func
(
bm
*
BlockManager
)
WatchAddr
(
addr
[]
byte
)
*
A
ccount
State
{
account
:=
bm
.
bc
.
CurrentBlock
.
state
.
GetAccount
(
addr
)
account
:=
bm
.
bc
.
CurrentBlock
.
state
.
GetAccount
(
addr
)
return
bm
.
addrStateStore
.
Add
(
addr
,
account
)
return
bm
.
addrStateStore
.
Add
(
addr
,
account
)
}
}
func
(
bm
*
BlockManager
)
GetAddrState
(
addr
[]
byte
)
*
A
ddress
State
{
func
(
bm
*
BlockManager
)
GetAddrState
(
addr
[]
byte
)
*
A
ccount
State
{
account
:=
bm
.
addrStateStore
.
Get
(
addr
)
account
:=
bm
.
addrStateStore
.
Get
(
addr
)
if
account
==
nil
{
if
account
==
nil
{
a
:=
bm
.
bc
.
CurrentBlock
.
state
.
GetAccount
(
addr
)
a
:=
bm
.
bc
.
CurrentBlock
.
state
.
GetAccount
(
addr
)
account
=
&
A
ddress
State
{
Nonce
:
a
.
Nonce
,
Account
:
a
}
account
=
&
A
ccount
State
{
Nonce
:
a
.
Nonce
,
Account
:
a
}
}
}
return
account
return
account
...
...
ethchain/state.go
View file @
9d492b05
...
@@ -93,18 +93,18 @@ func Compile(code []string) (script []string) {
...
@@ -93,18 +93,18 @@ func Compile(code []string) (script []string) {
return
return
}
}
func
(
s
*
State
)
GetAccount
(
addr
[]
byte
)
(
account
*
A
ddress
)
{
func
(
s
*
State
)
GetAccount
(
addr
[]
byte
)
(
account
*
A
ccount
)
{
data
:=
s
.
trie
.
Get
(
string
(
addr
))
data
:=
s
.
trie
.
Get
(
string
(
addr
))
if
data
==
""
{
if
data
==
""
{
account
=
NewA
ddress
(
big
.
NewInt
(
0
))
account
=
NewA
ccount
(
big
.
NewInt
(
0
))
}
else
{
}
else
{
account
=
NewA
ddress
FromData
([]
byte
(
data
))
account
=
NewA
ccount
FromData
([]
byte
(
data
))
}
}
return
return
}
}
func
(
s
*
State
)
UpdateAccount
(
addr
[]
byte
,
account
*
A
ddress
)
{
func
(
s
*
State
)
UpdateAccount
(
addr
[]
byte
,
account
*
A
ccount
)
{
s
.
trie
.
Update
(
string
(
addr
),
string
(
account
.
RlpEncode
()))
s
.
trie
.
Update
(
string
(
addr
),
string
(
account
.
RlpEncode
()))
}
}
...
...
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