File tree Expand file tree Collapse file tree 5 files changed +23
-15
lines changed
Framework/NethereumWorkflow
ProjectPlugins/CodexContractsPlugin
Tests/CodexReleaseTests/MarketTests Expand file tree Collapse file tree 5 files changed +23
-15
lines changed Original file line number Diff line number Diff line change @@ -146,7 +146,13 @@ public BlockTimeEntry GetBlockForNumber(ulong number)
146
146
147
147
public BlockWithTransactions GetBlockWithTransactions ( ulong number )
148
148
{
149
- return Time . Wait ( web3 . Eth . Blocks . GetBlockWithTransactionsByNumber . SendRequestAsync ( new BlockParameter ( number ) ) ) ;
149
+ var retry = new Retry ( nameof ( GetBlockWithTransactions ) ,
150
+ maxTimeout : TimeSpan . FromMinutes ( 1.0 ) ,
151
+ sleepAfterFail : TimeSpan . FromSeconds ( 1.0 ) ,
152
+ onFail : f => { } ,
153
+ failFast : false ) ;
154
+
155
+ return retry . Run ( ( ) => Time . Wait ( web3 . Eth . Blocks . GetBlockWithTransactionsByNumber . SendRequestAsync ( new BlockParameter ( number ) ) ) ) ;
150
156
}
151
157
}
152
158
}
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ public interface ICodexContractsEvents
19
19
SlotFreedEventDTO [ ] GetSlotFreedEvents ( ) ;
20
20
SlotReservationsFullEventDTO [ ] GetSlotReservationsFullEvents ( ) ;
21
21
ProofSubmittedEventDTO [ ] GetProofSubmittedEvents ( ) ;
22
- ReserveSlotFunction [ ] GetReserveSlotCalls ( ) ;
22
+ void GetReserveSlotCalls ( Action < ReserveSlotFunction > onFunction ) ;
23
23
}
24
24
25
25
public class CodexContractsEvents : ICodexContractsEvents
@@ -100,15 +100,13 @@ public ProofSubmittedEventDTO[] GetProofSubmittedEvents()
100
100
return events . Select ( SetBlockOnEvent ) . ToArray ( ) ;
101
101
}
102
102
103
- public ReserveSlotFunction [ ] GetReserveSlotCalls ( )
103
+ public void GetReserveSlotCalls ( Action < ReserveSlotFunction > onFunction )
104
104
{
105
- var result = new List < ReserveSlotFunction > ( ) ;
106
105
gethNode . IterateFunctionCalls < ReserveSlotFunction > ( BlockInterval , ( b , fn ) =>
107
106
{
108
107
fn . Block = b ;
109
- result . Add ( fn ) ;
108
+ onFunction ( fn ) ;
110
109
} ) ;
111
- return result . ToArray ( ) ;
112
110
}
113
111
114
112
private T SetBlockOnEvent < T > ( EventLog < T > e ) where T : IHasBlock
Original file line number Diff line number Diff line change @@ -266,9 +266,10 @@ protected void WaitForContractStarted(IStoragePurchaseContract r)
266
266
// should have filled the slot.
267
267
268
268
var requestId = r . PurchaseId . ToLowerInvariant ( ) ;
269
- var calls = GetContracts ( ) . GetEvents ( GetTestRunTimeRange ( ) ) . GetReserveSlotCalls ( ) ;
269
+ var calls = new List < ReserveSlotFunction > ( ) ;
270
+ GetContracts ( ) . GetEvents ( GetTestRunTimeRange ( ) ) . GetReserveSlotCalls ( calls . Add ) ;
270
271
271
- Log ( $ "Request '{ requestId } ' failed to start. There were { calls . Length } hosts who called reserve-slot for it:") ;
272
+ Log ( $ "Request '{ requestId } ' failed to start. There were { calls . Count } hosts who called reserve-slot for it:") ;
272
273
foreach ( var c in calls )
273
274
{
274
275
Log ( $ " - { c . Block . Utc } Host: { c . FromAddress } RequestId: { c . RequestId . ToHex ( ) } SlotIndex: { c . SlotIndex } ") ;
Original file line number Diff line number Diff line change @@ -36,7 +36,15 @@ public TimeRange TraceChainTimeline()
36
36
37
37
// For this timeline, we log all the calls to reserve-slot.
38
38
var events = contracts . GetEvents ( requestTimeline ) ;
39
- output . LogReserveSlotCalls ( Filter ( events . GetReserveSlotCalls ( ) ) ) ;
39
+
40
+ events . GetReserveSlotCalls ( call =>
41
+ {
42
+ if ( IsThisRequest ( call . RequestId ) )
43
+ {
44
+ output . LogReserveSlotCall ( call ) ;
45
+ log . Log ( "Found reserve-slot call for slotIndex " + call . SlotIndex ) ;
46
+ }
47
+ } ) ;
40
48
41
49
log . Log ( "Writing blockchain output..." ) ;
42
50
output . WriteContractEvents ( ) ;
@@ -67,11 +75,6 @@ private DateTime RunToContractEnd(Request request)
67
75
return tracker . FinishUtc ;
68
76
}
69
77
70
- private ReserveSlotFunction [ ] Filter ( ReserveSlotFunction [ ] calls )
71
- {
72
- return calls . Where ( c => IsThisRequest ( c . RequestId ) ) . ToArray ( ) ;
73
- }
74
-
75
78
private Request ? GetRequest ( )
76
79
{
77
80
var request = FindRequest ( LastHour ( ) ) ;
Original file line number Diff line number Diff line change @@ -113,7 +113,7 @@ private void Write(Entry e)
113
113
log . Log ( $ "[{ Time . FormatTimestamp ( e . Utc ) } ] { e . Msg } ") ;
114
114
}
115
115
116
- private void LogReserveSlotCall ( ReserveSlotFunction call )
116
+ public void LogReserveSlotCall ( ReserveSlotFunction call )
117
117
{
118
118
Add ( call . Block . Utc , $ "Reserve-slot called. Index: { call . SlotIndex } Host: '{ call . FromAddress } '") ;
119
119
}
You can’t perform that action at this time.
0 commit comments