@@ -12,7 +12,13 @@ import (
12
12
// QueryTransactionRange queries a list of transactions from RPC server, and does necessary
13
13
// crypto verifications.
14
14
func (c * Client ) QueryTransactionRange (ctx context.Context , start , limit uint64 , withEvents bool ) (* types.ProvenTransactionList , error ) {
15
+ c .accMu .RLock ()
16
+ frozenSubtreeRoots := cloneSubtrees (c .acc .FrozenSubtreeRoots )
17
+ numLeaves := c .acc .NumLeaves
18
+ c .accMu .RUnlock ()
19
+
15
20
resp , err := c .ac .UpdateToLatestLedger (ctx , & pbtypes.UpdateToLatestLedgerRequest {
21
+ ClientKnownVersion : numLeaves - 1 ,
16
22
RequestedItems : []* pbtypes.RequestItem {
17
23
{
18
24
RequestedItems : & pbtypes.RequestItem_GetTransactionsRequest {
@@ -32,13 +38,10 @@ func (c *Client) QueryTransactionRange(ctx context.Context, start, limit uint64,
32
38
// b, err := json.MarshalIndent(resp, "", " ")
33
39
// log.Printf("resp: %s", string(b))
34
40
35
- li := & types.LedgerInfoWithSignatures {}
36
- li .FromProto (resp .LedgerInfoWithSigs )
37
- pli , err := li .Verify (c .verifier )
41
+ pli , err := c .verifyLedgerInfoAndConsistency (resp , numLeaves , frozenSubtreeRoots )
38
42
if err != nil {
39
- return nil , fmt . Errorf ( "ledger info verification failed: %v" , err )
43
+ return nil , err
40
44
}
41
- // log.Printf("Ledger info: version %d, time %d", li.LedgerInfo.Version, li.LedgerInfo.TimestampUsec)
42
45
43
46
txnList := & types.TransactionListWithProof {}
44
47
err = txnList .FromProtoResponse (resp .ResponseItems [0 ].GetGetTransactionsResponse ())
@@ -59,7 +62,13 @@ func (c *Client) QueryTransactionRange(ctx context.Context, start, limit uint64,
59
62
// QueryTransactionByAccountSeq queries the transaction that is sent from a specific account at a specific sequence number,
60
63
// and does necessary crypto verifications.
61
64
func (c * Client ) QueryTransactionByAccountSeq (ctx context.Context , addr types.AccountAddress , sequence uint64 , withEvents bool ) (* types.ProvenTransaction , error ) {
65
+ c .accMu .RLock ()
66
+ frozenSubtreeRoots := cloneSubtrees (c .acc .FrozenSubtreeRoots )
67
+ numLeaves := c .acc .NumLeaves
68
+ c .accMu .RUnlock ()
69
+
62
70
resp , err := c .ac .UpdateToLatestLedger (ctx , & pbtypes.UpdateToLatestLedgerRequest {
71
+ ClientKnownVersion : numLeaves - 1 ,
63
72
RequestedItems : []* pbtypes.RequestItem {
64
73
{
65
74
RequestedItems : & pbtypes.RequestItem_GetAccountTransactionBySequenceNumberRequest {
@@ -79,13 +88,10 @@ func (c *Client) QueryTransactionByAccountSeq(ctx context.Context, addr types.Ac
79
88
// b, err := json.MarshalIndent(resp, "", " ")
80
89
// log.Printf("resp: %s", string(b))
81
90
82
- li := & types.LedgerInfoWithSignatures {}
83
- li .FromProto (resp .LedgerInfoWithSigs )
84
- pli , err := li .Verify (c .verifier )
91
+ pli , err := c .verifyLedgerInfoAndConsistency (resp , numLeaves , frozenSubtreeRoots )
85
92
if err != nil {
86
- return nil , fmt . Errorf ( "ledger info verification failed: %v" , err )
93
+ return nil , err
87
94
}
88
- // log.Printf("Ledger info: version %d, time %d", li.LedgerInfo.Version, li.LedgerInfo.TimestampUsec)
89
95
90
96
resp1 := resp .ResponseItems [0 ].GetGetAccountTransactionBySequenceNumberResponse ()
91
97
if resp1 == nil {
0 commit comments