@@ -68,6 +68,7 @@ type swapClientServer struct {
68
68
clientrpc.UnimplementedSwapClientServer
69
69
clientrpc.UnimplementedDebugServer
70
70
71
+ config * Config
71
72
network lndclient.Network
72
73
impl * loop.Client
73
74
liquidityMgr * liquidity.Manager
@@ -738,6 +739,77 @@ func (s *swapClientServer) GetLsatTokens(ctx context.Context,
738
739
return & clientrpc.TokensResponse {Tokens : rpcTokens }, nil
739
740
}
740
741
742
+ // GetInfo returns basic information about the loop daemon and details to swaps
743
+ // from the swap store.
744
+ func (s * swapClientServer ) GetInfo (_ context.Context ,
745
+ _ * clientrpc.GetInfoRequest ) (* clientrpc.GetInfoResponse , error ) {
746
+
747
+ // Fetch loop-outs from the loop db.
748
+ outSwaps , err := s .impl .Store .FetchLoopOutSwaps ()
749
+ if err != nil {
750
+ return nil , err
751
+ }
752
+
753
+ // Collect loop-out stats.
754
+ loopOutStats := & clientrpc.LoopStats {}
755
+ for _ , out := range outSwaps {
756
+ switch out .State ().State .Type () {
757
+ case loopdb .StateTypeSuccess :
758
+ loopOutStats .SuccessCount ++
759
+ loopOutStats .SumSucceededAmt += int64 (
760
+ out .Contract .AmountRequested ,
761
+ )
762
+
763
+ case loopdb .StateTypePending :
764
+ loopOutStats .PendingCount ++
765
+ loopOutStats .SumPendingAmt += int64 (
766
+ out .Contract .AmountRequested ,
767
+ )
768
+
769
+ case loopdb .StateTypeFail :
770
+ loopOutStats .FailCount ++
771
+ }
772
+ }
773
+
774
+ // Fetch loop-ins from the loop db.
775
+ inSwaps , err := s .impl .Store .FetchLoopInSwaps ()
776
+ if err != nil {
777
+ return nil , err
778
+ }
779
+
780
+ // Collect loop-in stats.
781
+ loopInStats := & clientrpc.LoopStats {}
782
+ for _ , in := range inSwaps {
783
+ switch in .State ().State .Type () {
784
+ case loopdb .StateTypeSuccess :
785
+ loopInStats .SuccessCount ++
786
+ loopInStats .SumSucceededAmt += int64 (
787
+ in .Contract .AmountRequested ,
788
+ )
789
+
790
+ case loopdb .StateTypePending :
791
+ loopInStats .PendingCount ++
792
+ loopInStats .SumPendingAmt += int64 (
793
+ in .Contract .AmountRequested ,
794
+ )
795
+
796
+ case loopdb .StateTypeFail :
797
+ loopInStats .FailCount ++
798
+ }
799
+ }
800
+
801
+ return & clientrpc.GetInfoResponse {
802
+ Version : loop .Version (),
803
+ Network : s .config .Network ,
804
+ RpcListen : s .config .RPCListen ,
805
+ RestListen : s .config .RESTListen ,
806
+ MacaroonPath : s .config .MacaroonPath ,
807
+ TlsCertPath : s .config .TLSCertPath ,
808
+ LoopOutStats : loopOutStats ,
809
+ LoopInStats : loopInStats ,
810
+ }, nil
811
+ }
812
+
741
813
// GetLiquidityParams gets our current liquidity manager's parameters.
742
814
func (s * swapClientServer ) GetLiquidityParams (_ context.Context ,
743
815
_ * clientrpc.GetLiquidityParamsRequest ) (* clientrpc.LiquidityParameters ,
0 commit comments