@@ -782,6 +782,7 @@ def channel(request):
782782 channels_df = DataFrame .from_records (channel .values ())
783783 rebalancer_df = DataFrame .from_records (Rebalancer .objects .filter (last_hop_pubkey = channels_df ['remote_pubkey' ][0 ]).annotate (ppm = Round ((Sum ('fee_limit' )* 1000000 )/ Sum ('value' ), output_field = IntegerField ())).order_by ('-id' ).values ())
784784 failed_htlc_df = DataFrame .from_records (FailedHTLCs .objects .exclude (wire_failure = 99 ).filter (Q (chan_id_in = chan_id ) | Q (chan_id_out = chan_id )).order_by ('-id' ).values ())
785+ peer_info_df = DataFrame .from_records (Peers .objects .filter (pubkey = channels_df ['remote_pubkey' ][0 ]).values ())
785786 channels_df ['local_balance' ] = channels_df ['local_balance' ] + channels_df ['pending_outbound' ]
786787 channels_df ['remote_balance' ] = channels_df ['remote_balance' ] + channels_df ['pending_inbound' ]
787788 channels_df ['in_percent' ] = ((channels_df ['remote_balance' ]/ channels_df ['capacity' ])* 100 ).round (0 ).astype (int )
@@ -1073,19 +1074,6 @@ def channel(request):
10731074 autofees_df = DataFrame .from_records (Autofees .objects .filter (chan_id = chan_id ).filter (timestamp__gte = filter_30day ).order_by ('-id' ).values ())
10741075 if autofees_df .shape [0 ]> 0 :
10751076 autofees_df ['change' ] = autofees_df .apply (lambda row : 0 if row .old_value == 0 else round ((row .new_value - row .old_value )* 100 / row .old_value , 1 ), axis = 1 )
1076- peer_events_df = DataFrame .from_records (PeerEvents .objects .filter (chan_id = chan_id ).order_by ('-id' )[:10 ].values ())
1077- if peer_events_df .shape [0 ]> 0 :
1078- peer_events_df ['change' ] = peer_events_df .apply (lambda row : 0 if row .old_value == 0 or row .old_value == None else round ((row .new_value - row .old_value )* 100 / row .old_value , 1 ), axis = 1 )
1079- peer_events_df ['out_percent' ] = round ((peer_events_df ['out_liq' ]/ channels_df ['capacity' ][0 ])* 100 , 1 )
1080- peer_events_df .loc [peer_events_df ['event' ]== 'MinHTLC' , 'old_value' ] = peer_events_df ['old_value' ]/ 1000
1081- peer_events_df .loc [peer_events_df ['event' ]== 'MinHTLC' , 'new_value' ] = peer_events_df ['new_value' ]/ 1000
1082- peer_events_df .loc [peer_events_df ['event' ]== 'MaxHTLC' , 'old_value' ] = peer_events_df ['old_value' ]/ 1000
1083- peer_events_df .loc [peer_events_df ['event' ]== 'MaxHTLC' , 'new_value' ] = peer_events_df ['new_value' ]/ 1000
1084- peer_events_df = peer_events_df .fillna ('' )
1085- peer_events_df .loc [peer_events_df ['old_value' ]!= '' , 'old_value' ] = peer_events_df .loc [peer_events_df ['old_value' ]!= '' , 'old_value' ].astype (int )
1086- peer_events_df .loc [peer_events_df ['new_value' ]!= '' , 'new_value' ] = peer_events_df .loc [peer_events_df ['new_value' ]!= '' , 'new_value' ].astype (int )
1087- peer_events_df ['out_percent' ] = peer_events_df ['out_percent' ].astype (int )
1088- peer_events_df ['in_percent' ] = (100 - peer_events_df ['out_percent' ])
10891077 results_df = af .main (channel )
10901078 channels_df ['new_rate' ] = results_df [results_df ['chan_id' ]== chan_id ]['new_rate' ]
10911079 channels_df ['adjustment' ] = results_df [results_df ['chan_id' ]== chan_id ]['adjustment' ]
@@ -1094,20 +1082,20 @@ def channel(request):
10941082 channels_df = DataFrame ()
10951083 payments_df = DataFrame ()
10961084 invoices_df = DataFrame ()
1085+ peer_info_df = DataFrame ()
10971086 autofees_df = DataFrame ()
1098- peer_events_df = DataFrame ()
10991087 context = {
11001088 'chan_id' : chan_id ,
11011089 'channel' : [] if channels_df .empty else channels_df .to_dict (orient = 'records' )[0 ],
11021090 'incoming_htlcs' : PendingHTLCs .objects .filter (chan_id = chan_id ).filter (incoming = True ).order_by ('hash_lock' ),
11031091 'outgoing_htlcs' : PendingHTLCs .objects .filter (chan_id = chan_id ).filter (incoming = False ).order_by ('hash_lock' ),
11041092 'payments' : [] if payments_df .empty else payments_df .sort_values (by = ['creation_date' ], ascending = False ).to_dict (orient = 'records' )[:5 ],
11051093 'invoices' : [] if invoices_df .empty else invoices_df .sort_values (by = ['settle_date' ], ascending = False ).to_dict (orient = 'records' )[:5 ],
1094+ 'peer_info' : [] if peer_info_df .empty else peer_info_df .to_dict (orient = 'records' )[0 ],
11061095 'network' : 'testnet/' if settings .LND_NETWORK == 'testnet' else '' ,
11071096 'graph_links' : graph_links (),
11081097 'network_links' : network_links (),
11091098 'autofees' : [] if autofees_df .empty else autofees_df .to_dict (orient = 'records' ),
1110- 'peer_events' : [] if peer_events_df .empty else peer_events_df .to_dict (orient = 'records' )
11111099 }
11121100 try :
11131101 return render (request , 'channel.html' , context )
0 commit comments