Skip to content

Commit 8fe3ae6

Browse files
tsachihermanjusticzalgobolsonEvanJRichardpzbitskiy
authored
Merge the indexer changes into the 2.0.3 release branch (#728)
* Prepare beta release build 9 (#673) * add lease to asset cmds (#575) * fix Disassemble when multiple bnz have the same target label (#612) add test * Add PeerConnections to network telemetry (#607) * Add PeerConnections to network telemetry. * omit Endpoint for incoming connections. * fix asset unit name display in goal account list (#633) * Add --no-sig flag to goal clerk multisig sign (#647) * add --no-sig flag to goal clerk multisig sign * update err message * change preimage -> template * change template -> information * Scan for ledger wallets more often (#638) * add more robust ledger scanning, fix infinite recursion bug * fix comment * undo scan change * still delete wallets we fail to close * Improve missing msig preimage error message (#648) * improve missing msig preimage error message * improve err msg * Add support for https for telemetry servers (#649) * Add support for https for telemetry servers. * typo : udo -> udp * Fixed few typos. * goal listpartkeys display error (#641) * Add logging for the telemetry server connections (#661) * Add logging for the telemetry server connections. * Revert unintended change. * Improve error message. * Avoid upgrading boost on travis Mac builds (#669) * specify a boost version for the mac build. * try to prevent boost update on travis mac builds. * Build 9 * Abort algod startup if logging.config file has bad permissions (#662) * This should prevent telemetry event loses on systems with invalid permissions on ~/.algorand/logging.config file * Another possible workaround is to relax default config path mask in **cmd/goal/commands.go:ensureCacheDir** from 700 to 744. This is not implemented because of possible security risk. Co-authored-by: Max Justicz <[email protected]> Co-authored-by: algobolson <[email protected]> Co-authored-by: Evan Richard <[email protected]> Co-authored-by: pzbitskiy <[email protected]> * update predicate * Fix - Indexer now shows received transactions (#684) (#688) -- Adding receiver function to transaction that returns the receiver of a transaction -- Fix indexer to show received transactions Co-authored-by: Rotem Hemo <[email protected]> Co-authored-by: Max Justicz <[email protected]> Co-authored-by: algobolson <[email protected]> Co-authored-by: Evan Richard <[email protected]> Co-authored-by: pzbitskiy <[email protected]> Co-authored-by: Rotem Hemo <[email protected]>
1 parent 3c8eef8 commit 8fe3ae6

File tree

3 files changed

+52
-4
lines changed

3 files changed

+52
-4
lines changed

data/transactions/transaction.go

+12
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,18 @@ func (tx Transaction) TxAmount() basics.MicroAlgos {
412412
}
413413
}
414414

415+
// GetReceiverAddress returns the address of the receiver. If the transaction has no receiver, it returns the empty address.
416+
func (tx Transaction) GetReceiverAddress() basics.Address {
417+
switch tx.Type {
418+
case protocol.PaymentTx:
419+
return tx.PaymentTxnFields.Receiver
420+
case protocol.AssetTransferTx:
421+
return tx.AssetTransferTxnFields.AssetReceiver
422+
default:
423+
return basics.Address{}
424+
}
425+
}
426+
415427
// EstimateEncodedSize returns the estimated encoded size of the transaction including the signature.
416428
// This function is to be used for calculating the fee
417429
func (tx Transaction) EstimateEncodedSize() int {

node/indexer/db.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func (idb *DB) AddBlock(b bookkeeping.Block) error {
124124
}
125125
for _, txad := range payset {
126126
txn := txad.SignedTxn
127-
_, err = stmt.Exec(txn.ID().String(), txn.Txn.Sender.String(), txn.Txn.Receiver.String(), b.Round(), b.TimeStamp)
127+
_, err = stmt.Exec(txn.ID().String(), txn.Txn.Sender.String(), txn.Txn.GetReceiverAddress().String(), b.Round(), b.TimeStamp)
128128
if err != nil {
129129
return err
130130
}

node/indexer/indexer_test.go

+39-3
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,31 @@ func (s *IndexSuite) TestIndexer_DuplicateRounds() {
124124
}
125125
}
126126

127+
func (s *IndexSuite) TestIndexer_Asset() {
128+
query := "SELECT txid from transactions where (from_addr = $1 OR to_addr = $1)"
129+
rows, err := s.idx.IDB.dbr.Handle.Query(query, s.addrs[0].String())
130+
require.NoError(s.T(), err)
131+
defer rows.Close()
132+
133+
txids := make(map[string]bool, 0)
134+
var txid string
135+
for rows.Next() {
136+
err := rows.Scan(&txid)
137+
require.NoError(s.T(), err)
138+
txids[txid] = true
139+
}
140+
141+
// make sure all txns are in list
142+
for _, txn := range s.txns {
143+
if txn.Txn.Type == protocol.AssetTransferTx {
144+
if txn.Txn.Sender == s.addrs[0] || txn.Txn.AssetReceiver == s.addrs[0] {
145+
require.True(s.T(), txids[txn.ID().String()])
146+
}
147+
}
148+
}
149+
150+
}
151+
127152
func TestExampleTestSuite(t *testing.T) {
128153
suite.Run(t, new(IndexSuite))
129154
}
@@ -201,17 +226,28 @@ func generateTestObjects(numTxs, numAccs int) ([]transactions.Transaction, []tra
201226
exp := iss + 10
202227

203228
txs[i] = transactions.Transaction{
204-
Type: protocol.PaymentTx,
205229
Header: transactions.Header{
206230
Sender: addresses[s],
207231
Fee: basics.MicroAlgos{Raw: f},
208232
FirstValid: basics.Round(iss),
209233
LastValid: basics.Round(exp),
210234
},
211-
PaymentTxnFields: transactions.PaymentTxnFields{
235+
}
236+
237+
// Create half assets and half payment
238+
if i%2 == 0 {
239+
txs[i].Type = protocol.PaymentTx
240+
txs[i].PaymentTxnFields = transactions.PaymentTxnFields{
212241
Receiver: addresses[r],
213242
Amount: basics.MicroAlgos{Raw: uint64(a)},
214-
},
243+
}
244+
} else {
245+
txs[i].Type = protocol.AssetTransferTx
246+
txs[i].AssetTransferTxnFields = transactions.AssetTransferTxnFields{
247+
AssetReceiver: addresses[r],
248+
AssetAmount: uint64(a),
249+
XferAsset: basics.AssetIndex(uint64(rand.Intn(20000))),
250+
}
215251
}
216252
signed[i] = txs[i].Sign(secrets[s])
217253
}

0 commit comments

Comments
 (0)