Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Picks for s3 #2068

Merged
merged 3 commits into from
Jan 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions internal/hmyapi/harmony.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -64,6 +65,7 @@ func (s *PublicHarmonyAPI) GetNodeMetadata() NodeMetadata {
s.b.ChainConfig().ChainID.String(),
s.b.IsLeader(),
s.b.GetShardID(),
cfg.Role().String(),
}
}

Expand Down
20 changes: 3 additions & 17 deletions internal/hmyapi/transactionpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down