mirror of https://github.com/poanetwork/quorum.git
private: Distinguish between privateFor being absent vs. an empty array to allow self-sending (#165)
This commit is contained in:
parent
5dfdecef4c
commit
9faa0ed123
|
@ -277,7 +277,7 @@ func (s *PrivateAccountAPI) SendTransaction(ctx context.Context, args SendTxArgs
|
|||
|
||||
var tx *types.Transaction
|
||||
data := common.FromHex(args.Data)
|
||||
isPrivate := len(args.PrivateFor) > 0
|
||||
isPrivate := args.PrivateFor != nil
|
||||
if isPrivate {
|
||||
data, err = private.P.Send(data, args.PrivateFrom, args.PrivateFor)
|
||||
if err != nil {
|
||||
|
@ -377,7 +377,7 @@ func (a *Async) save(ctx context.Context, s *PublicTransactionPoolAPI, args Send
|
|||
if err != nil {
|
||||
return common.Hash{}, err
|
||||
}
|
||||
return submitTransaction(ctx, s.b, tx, signature, len(args.PrivateFor) > 0)
|
||||
return submitTransaction(ctx, s.b, tx, signature, args.PrivateFor != nil)
|
||||
}
|
||||
|
||||
func newAsync(n int) *Async {
|
||||
|
@ -1202,7 +1202,7 @@ func (s *PublicTransactionPoolAPI) SendTransaction(ctx context.Context, args Sen
|
|||
|
||||
var tx *types.Transaction
|
||||
data := common.FromHex(args.Data)
|
||||
isPrivate := len(args.PrivateFor) > 0
|
||||
isPrivate := args.PrivateFor != nil
|
||||
if isPrivate {
|
||||
data, err = private.P.Send(data, args.PrivateFrom, args.PrivateFor)
|
||||
if err != nil {
|
||||
|
|
|
@ -6,28 +6,15 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
func copyBytes(b []byte) []byte {
|
||||
ob := make([]byte, len(b))
|
||||
copy(ob, b)
|
||||
return ob
|
||||
}
|
||||
|
||||
type Constellation struct {
|
||||
node *Client
|
||||
c *cache.Cache
|
||||
}
|
||||
|
||||
func (g *Constellation) Send(data []byte, from string, to []string) (out []byte, err error) {
|
||||
if len(data) > 0 {
|
||||
if len(to) == 0 {
|
||||
out = copyBytes(data)
|
||||
} else {
|
||||
var err error
|
||||
out, err = g.node.SendPayload(data, from, to)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
out, err = g.node.SendPayload(data, from, to)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
g.c.Set(string(out), data, cache.DefaultExpiration)
|
||||
return out, nil
|
||||
|
|
Loading…
Reference in New Issue