Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
contrib
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
2
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blockchain
contrib
Commits
35327557
Commit
35327557
authored
5 years ago
by
Miguel Montes
Browse files
Options
Downloads
Patches
Plain Diff
Agregado reporte de transferencias
parent
89e163ff
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bfa_client/src/bfa/block.go
+8
-0
8 additions, 0 deletions
bfa_client/src/bfa/block.go
bfa_client/src/bfa/node.go
+12
-0
12 additions, 0 deletions
bfa_client/src/bfa/node.go
bfa_client/src/client/bfa_client.go
+71
-0
71 additions, 0 deletions
bfa_client/src/client/bfa_client.go
with
91 additions
and
0 deletions
bfa_client/src/bfa/block.go
+
8
−
0
View file @
35327557
...
...
@@ -28,6 +28,10 @@ func (bigInt *BigInt) UnmarshalJSON(b []byte) error {
}
func
(
bigInt
*
BigInt
)
String
()
string
{
return
(
*
big
.
Int
)(
bigInt
)
.
String
()
}
func
(
bigInt
*
BigInt
)
Int64
()
int64
{
return
(
*
big
.
Int
)(
bigInt
)
.
Int64
()
}
...
...
@@ -36,6 +40,10 @@ func (bigInt *BigInt) Uint64() uint64 {
return
(
*
big
.
Int
)(
bigInt
)
.
Uint64
()
}
func
(
bigInt
*
BigInt
)
IsZero
()
bool
{
return
(
*
big
.
Int
)(
bigInt
)
.
BitLen
()
==
0
}
type
Uint64
uint64
func
(
u
*
Uint64
)
UnmarshalJSON
(
b
[]
byte
)
(
err
error
)
{
...
...
This diff is collapsed.
Click to expand it.
bfa_client/src/bfa/node.go
+
12
−
0
View file @
35327557
...
...
@@ -3,6 +3,7 @@ package bfa
import
(
.
"../util"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/consensus/clique"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/rpc"
...
...
@@ -65,6 +66,11 @@ func (node *Node) BlockNumber() int64 {
return
bn
.
Int64
()
}
func
(
node
*
Node
)
GasPrice
()
(
gp
int64
)
{
node
.
Call
(
&
gp
,
"eth_gasPrice"
)
return
gp
}
func
(
node
*
Node
)
Accounts
()
(
accounts
[]
string
)
{
node
.
Call
(
&
accounts
,
"eth_accounts"
)
return
...
...
@@ -142,6 +148,12 @@ func (node *Node) BlockByHash(hash common.Hash) (block Block) {
return
}
func
(
node
*
Node
)
BlockTransactionCount
(
blockNumber
int64
)
(
count
int64
)
{
var
num
hexutil
.
Uint64
node
.
Call
(
&
num
,
"eth_getBlockTransactionCountByNumber"
,
hexBlockNumber
(
blockNumber
))
return
int64
(
num
)
}
func
(
node
*
Node
)
BlockSigner
(
blockNumber
int64
)
(
signer
common
.
Address
)
{
if
blockNumber
==
0
{
// we return an empty signer for genesis block
return
...
...
This diff is collapsed.
Click to expand it.
bfa_client/src/client/bfa_client.go
+
71
−
0
View file @
35327557
...
...
@@ -502,6 +502,76 @@ func snapshot() {
util
.
PrintJson
(
snapshot
)
}
func
transfers
()
{
type
Transfer
struct
{
From
string
`json:"from"`
To
string
`json:"to"`
Amount
*
big
.
Int
`json:"amount"`
BlockNumber
int64
`json:"blockNumber"`
}
var
(
first
,
last
,
end
int64
)
description
=
"Muestra transferencias en un rango de bloques, y opcionalmente, restringidas a ciertas direcciones."
otherArgs
=
"[dirección...]"
setFlags
()
flags
.
Int64Var
(
&
first
,
"first-block"
,
latest
,
"Primer bloque del rango (-1 para especificar el último bloque)"
)
flags
.
Int64Var
(
&
last
,
"last-block"
,
latest
,
"Último bloque del rango (-1 para especificar el último bloque)"
)
parseFlags
(
true
)
url
=
updateURL
(
url
)
node
,
err
:=
bfa
.
Dial
(
url
)
util
.
Check
(
err
)
defer
node
.
Close
()
set
:=
make
(
map
[
common
.
Address
]
bool
)
txs
:=
make
([]
Transfer
,
0
)
for
i
:=
0
;
i
<
flags
.
NArg
();
i
++
{
address
:=
flags
.
Arg
(
i
)
util
.
Ensure
(
util
.
IsAddress
(
address
),
"'%v' no es una dirección válida"
,
address
)
set
[
common
.
HexToAddress
(
address
)]
=
true
}
latest
:=
node
.
BlockNumber
()
if
first
<
0
{
first
=
latest
}
if
last
<
0
||
last
>
latest
{
end
=
latest
+
1
}
else
{
end
=
last
+
1
}
for
first
<
end
{
for
i
:=
first
;
i
<
end
;
i
++
{
if
node
.
BlockTransactionCount
(
i
)
>
0
{
block
:=
node
.
BlockByNumber
(
i
)
for
_
,
transaction
:=
range
block
.
Transactions
{
if
!
transaction
.
Value
.
IsZero
()
{
src
:=
transaction
.
From
dst
:=
transaction
.
To
if
len
(
set
)
==
0
||
set
[
src
]
||
set
[
dst
]
{
if
json
{
txs
=
append
(
txs
,
Transfer
{
src
.
Hex
(),
dst
.
Hex
(),
(
*
big
.
Int
)(
transaction
.
Value
),
i
})
}
else
{
fmt
.
Printf
(
"%v -> %v: %v (%v)
\n
"
,
src
.
Hex
(),
dst
.
Hex
(),
transaction
.
Value
,
transaction
.
BlockNumber
)
}
}
}
}
}
}
first
=
end
if
last
<
0
||
last
>
end
{
latest
=
node
.
BlockNumber
()
if
latest
<
last
{
end
=
latest
+
1
}
else
{
end
=
last
+
1
}
}
}
if
json
{
util
.
PrintJson
(
txs
)
}
}
func
main
()
{
var
(
commands
=
map
[
string
]
func
(){
...
...
@@ -512,6 +582,7 @@ func main() {
"status"
:
status
,
"block"
:
block
,
"snapshot"
:
snapshot
,
"transfers"
:
transfers
,
}
validCommands
[]
string
command
func
()
...
...
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