Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
burrow
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hang Yu
burrow
Commits
f819a37a
Unverified
Commit
f819a37a
authored
8 years ago
by
Benjamin Bollen
Browse files
Options
Downloads
Patches
Plain Diff
client: further assertion on eris-client tx send
parent
604f1e65
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
client/core/core.go
+44
-27
44 additions, 27 deletions
client/core/core.go
client/transaction/transaction.go
+31
-4
31 additions, 4 deletions
client/transaction/transaction.go
with
75 additions
and
31 deletions
client/core/core.go
+
44
−
27
View file @
f819a37a
...
...
@@ -31,7 +31,6 @@ import (
"github.com/tendermint/go-rpc/client"
// ptypes "github.com/eris-ltd/permission/types"
// cclient "github.com/eris-ltd/tendermint/rpc/client"
log
"github.com/eris-ltd/eris-logger"
...
...
@@ -315,7 +314,7 @@ func Pub(addr, rpcAddr string) (pubBytes []byte, err error) {
func
Sign
(
signBytes
,
signAddr
,
signRPC
string
)
(
sig
[
64
]
byte
,
err
error
)
{
args
:=
map
[
string
]
string
{
"msg"
:
signBytes
,
"hash"
:
signBytes
,
// backwards compatibility
"hash"
:
signBytes
,
//
TODO:[ben]
backwards compatibility
"addr"
:
signAddr
,
}
sigS
,
err
:=
RequestResponse
(
signRPC
,
"sign"
,
args
)
...
...
@@ -484,7 +483,9 @@ func SignAndBroadcast(chainID, nodeAddr, signAddr string, tx txs.Tx, sign, broad
// // if broadcast threw an error, just return
// return
// }
// logger.Debugln("Waiting for tx to be committed ...")
// log.WithFields(log.Fields{
// "",
// }).Debug("Waiting for tx to be committed")
// msg := <-ch
// if msg.Error != nil {
// logger.Infof("Encountered error waiting for event: %v\n", msg.Error)
...
...
@@ -506,8 +507,8 @@ func SignAndBroadcast(chainID, nodeAddr, signAddr string, tx txs.Tx, sign, broad
Hash
:
receipt
.
TxHash
,
}
// NOTE: [ben] is this consistent with the Ethereum protocol? It should seem
// reasonable to get this returned from the chain directly.
The returned benefit
// is that the we don't need to trust the chain node
// reasonable to get this returned from the chain directly.
Alternatively,
//
the benefit
is that the we don't need to trust the chain node
if
tx_
,
ok
:=
tx
.
(
*
txs
.
CallTx
);
ok
{
if
len
(
tx_
.
Address
)
==
0
{
txResult
.
Address
=
txs
.
NewContractAddress
(
tx_
.
Input
.
Address
,
tx_
.
Input
.
Sequence
)
...
...
@@ -517,28 +518,43 @@ func SignAndBroadcast(chainID, nodeAddr, signAddr string, tx txs.Tx, sign, broad
return
}
//
//------------------------------------------------------------------------------------
//
// wait for events
//------------------------------------------------------------------------------------
// wait for events
//
type Msg struct {
//
BlockHash []byte
//
Value []byte
//
Exception string
//
Error error
//
}
type
Msg
struct
{
BlockHash
[]
byte
Value
[]
byte
Exception
string
Error
error
}
// func subscribeAndWait(tx t
ype
s.Tx, chainID, nodeAddr string, inputAddr []byte) (chan Msg, error) {
// func subscribeAndWait(tx t
x
s.Tx, chainID, nodeAddr string, inputAddr []byte) (chan Msg, error) {
// // subscribe to event and wait for tx to be committed
// wsAddr := strings.TrimPrefix(nodeAddr, "http://")
// wsAddr = "ws://" + wsAddr + "websocket"
// logger.Debugf("Websocket Address %s\n", wsAddr)
// wsClient := cclient.NewWSClient(wsAddr)
// var wsAddr string
// if strings.HasPrefix(nodeAddr, "http://") {
// wsAddr = strings.TrimPrefix(nodeAddr, "http://")
// }
// if strings.HasPrefix(nodeAddr, "tcp://") {
// wsAddr = strings.TrimPrefix(nodeAddr, "tcp://")
// }
// if strings.HasPrefix(nodeAddr, "unix://") {
// log.WithFields(log.Fields{
// "node address": nodeAddr,
// }).Warn("Unable to subscribe to websocket from unix socket.")
// return nil, fmt.Errorf("Unable to subscribe to websocket from unix socket: %s", nodeAddr)
// }
// wsAddr = "ws://" + wsAddr
// log.WithFields(log.Fields{
// "websocket address": wsAddr,
// "endpoint": "/websocket",
// }).Debug("Subscribing to websocket address")
// wsClient := rpcclient.NewWSClient(wsAddr, "/websocket")
// wsClient.Start()
// eid := t
ype
s.EventStringAccInput(inputAddr)
// eid := t
x
s.EventStringAccInput(inputAddr)
// if err := wsClient.Subscribe(eid); err != nil {
// return nil, fmt.Errorf("Error subscribing to AccInput event: %v", err)
// }
// if err := wsClient.Subscribe(t
ype
s.EventStringNewBlock()); err != nil {
// if err := wsClient.Subscribe(t
x
s.EventStringNewBlock()); err != nil {
// return nil, fmt.Errorf("Error subscribing to NewBlock event: %v", err)
// }
...
...
@@ -551,9 +567,9 @@ func SignAndBroadcast(chainID, nodeAddr, signAddr string, tx txs.Tx, sign, broad
// for {
// result := <-wsClient.EventsCh
// // if its a block, remember the block hash
// blockData, ok := result.Data.(t
ype
s.EventDataNewBlock)
// blockData, ok := result.Data.(t
x
s.EventDataNewBlock)
// if ok {
// log
ger
.Infoln(blockData.Block)
// log.Infoln(blockData.Block)
// latestBlockHash = blockData.Block.Hash()
// continue
// }
...
...
@@ -653,16 +669,12 @@ func checkCommon(nodeAddr, signAddr, pubkey, addr, amtS, nonceS string) (pub cry
if
nonceS
==
""
{
if
nodeAddr
==
""
{
err
=
fmt
.
Errorf
(
"input must specify a nonce with the --nonce flag or use --node-addr (or
MI
NT
X
_NODE_ADDR) to fetch the nonce from a node"
)
err
=
fmt
.
Errorf
(
"input must specify a nonce with the --nonce flag or use --node-addr (or
ERIS_CLIE
NT_NODE_ADDR) to fetch the nonce from a node"
)
return
}
// fetch nonce from node
client
:=
rpcclient
.
NewClientURI
(
nodeAddr
)
log
.
WithFields
(
log
.
Fields
{
"node address"
:
nodeAddr
,
"account address"
:
fmt
.
Sprintf
(
"%X"
,
addrBytes
),
})
.
Debug
(
"Fetch nonce from node"
)
account
,
err2
:=
tendermint_client
.
GetAccount
(
client
,
addrBytes
)
if
err2
!=
nil
{
err
=
fmt
.
Errorf
(
"Error connecting to node (%s) to fetch nonce: %s"
,
nodeAddr
,
err2
.
Error
())
...
...
@@ -673,6 +685,11 @@ func checkCommon(nodeAddr, signAddr, pubkey, addr, amtS, nonceS string) (pub cry
return
}
nonce
=
int64
(
account
.
Sequence
)
+
1
log
.
WithFields
(
log
.
Fields
{
"nonce"
:
nonce
,
"node address"
:
nodeAddr
,
"account address"
:
fmt
.
Sprintf
(
"%X"
,
addrBytes
),
})
.
Debug
(
"Fetch nonce from node"
)
}
else
{
nonce
,
err
=
strconv
.
ParseInt
(
nonceS
,
10
,
64
)
if
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
client/transaction/transaction.go
+
31
−
4
View file @
f819a37a
...
...
@@ -17,8 +17,9 @@
package
transaction
import
(
//
"fmt"
"fmt"
// "io/ioutil"
"os"
log
"github.com/eris-ltd/eris-logger"
...
...
@@ -32,7 +33,33 @@ func Send(do *definitions.ClientDo) {
if
err
!=
nil
{
log
.
Fatalf
(
"Failed on Send Transaction: %s"
,
err
)
}
//
unpackSignAndBroadcast(
unpackSignAndBroadcast
(
core
.
SignAndBroadcast
(
do
.
ChainidFlag
,
do
.
NodeAddrFlag
,
do
.
SignAddrFlag
,
sendTransaction
,
true
,
do
.
BroadcastFlag
,
do
.
WaitFlag
)
//)
}
\ No newline at end of file
do
.
SignAddrFlag
,
sendTransaction
,
true
,
do
.
BroadcastFlag
,
do
.
WaitFlag
))
}
//----------------------------------------------------------------------
// Helper functions
func
unpackSignAndBroadcast
(
result
*
core
.
TxResult
,
err
error
)
{
if
err
!=
nil
{
log
.
Fatalf
(
"Failed on signing (and broadcasting) transaction: %s"
,
err
)
os
.
Exit
(
1
)
}
if
result
==
nil
{
// if we don't provide --sign or --broadcast
return
}
printResult
:=
log
.
Fields
{
"transaction hash"
:
fmt
.
Sprintf
(
"%X"
,
result
.
Hash
),
}
if
result
.
Address
!=
nil
{
printResult
[
"Contract Address"
]
=
fmt
.
Sprintf
(
"%X"
,
result
.
Address
)
}
if
result
.
Return
!=
nil
{
printResult
[
"Block Hash"
]
=
fmt
.
Sprintf
(
"%X"
,
result
.
BlockHash
)
printResult
[
"Return Value"
]
=
fmt
.
Sprintf
(
"%X"
,
result
.
Return
)
printResult
[
"Exception"
]
=
fmt
.
Sprintf
(
"%s"
,
result
.
Exception
)
}
log
.
WithFields
(
printResult
)
.
Warn
(
"Result"
)
}
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