From 97ebb3792f51cbf464f8b5f4814f518335d23361 Mon Sep 17 00:00:00 2001 From: Edgar Aroutiounian Date: Wed, 8 Jan 2020 16:22:30 -0800 Subject: [PATCH 1/2] [rpc] Expose nodes role into Metadata RPC (#2052) --- internal/hmyapi/harmony.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/hmyapi/harmony.go b/internal/hmyapi/harmony.go index 67bd864c0a..e5dc12e29e 100644 --- a/internal/hmyapi/harmony.go +++ b/internal/hmyapi/harmony.go @@ -52,6 +52,7 @@ type NodeMetadata struct { ChainID string `json:"chainid"` IsLeader bool `json:"is-leader"` ShardID uint32 `json:"shard-id"` + Role string `json:"role"` } // GetNodeMetadata produces a NodeMetadata record, data is from the answering RPC node @@ -64,6 +65,7 @@ func (s *PublicHarmonyAPI) GetNodeMetadata() NodeMetadata { s.b.ChainConfig().ChainID.String(), s.b.IsLeader(), s.b.GetShardID(), + cfg.Role().String(), } } From b2210fa8ed5ed04cd737b17377f6f3832fae83ae Mon Sep 17 00:00:00 2001 From: Edgar Aroutiounian Date: Fri, 10 Jan 2020 19:29:36 -0800 Subject: [PATCH 2/2] [rpc] Simplify Pending txn (#2065) --- internal/hmyapi/transactionpool.go | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/internal/hmyapi/transactionpool.go b/internal/hmyapi/transactionpool.go index 8ab948dbd3..c05065a080 100644 --- a/internal/hmyapi/transactionpool.go +++ b/internal/hmyapi/transactionpool.go @@ -270,28 +270,14 @@ func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, ha } // PendingTransactions returns the transactions that are in the transaction pool -// and have a from address that is one of the accounts this node manages. func (s *PublicTransactionPoolAPI) PendingTransactions() ([]*RPCTransaction, error) { pending, err := s.b.GetPoolTransactions() if err != nil { return nil, err } - accounts := make(map[common.Address]struct{}) - for _, wallet := range s.b.AccountManager().Wallets() { - for _, account := range wallet.Accounts() { - accounts[account.Address] = struct{}{} - } - } - transactions := make([]*RPCTransaction, 0, len(pending)) - for _, tx := range pending { - var signer types.Signer = types.HomesteadSigner{} - if tx.Protected() { - signer = types.NewEIP155Signer(tx.ChainID()) - } - from, _ := types.Sender(signer, tx) - if _, exists := accounts[from]; exists { - transactions = append(transactions, newRPCPendingTransaction(tx)) - } + transactions := make([]*RPCTransaction, len(pending)) + for i := range pending { + transactions[i] = newRPCPendingTransaction(pending[i]) } return transactions, nil }