@@ -2,7 +2,6 @@ package cmd
22
33import (
44 "fmt"
5- "log"
65
76 "github.com/0chain/gosdk/core/common"
87 "github.com/0chain/gosdk/zboxcore/fileref"
@@ -17,7 +16,7 @@ func calculateDownloadCost(alloc *sdk.Allocation, fileSize int64, numBlocks int6
1716 for _ , d := range alloc .BlobberDetails {
1817 readPrice , err := d .Terms .ReadPrice .ToToken ()
1918 if err != nil {
20- log . Fatalf ("failed to convert %v to token, %v" , d .Terms .ReadPrice , err )
19+ Fatalf ("failed to convert %v to token, %v" , d .Terms .ReadPrice , err )
2120 }
2221
2322 cost += sizeInGB (numBlocks * fileref .CHUNK_SIZE ) * float64 (readPrice )
@@ -26,14 +25,14 @@ func calculateDownloadCost(alloc *sdk.Allocation, fileSize int64, numBlocks int6
2625
2726 balance , err := common .ToBalance (cost )
2827 if err != nil {
29- log . Fatalf ("failed to convert %v to balance, %v" , cost , err )
28+ Fatalf ("failed to convert %v to balance, %v" , cost , err )
3029 }
3130 return balance
3231}
3332
3433func downloadCost (alloc * sdk.Allocation , meta * sdk.ConsolidatedFileMeta , blocksPerMarker int ) {
3534 if meta .Type != fileref .FILE {
36- log . Fatal ("not a file" )
35+ Fatal ("not a file" )
3736 }
3837
3938 shardSize := (meta .ActualFileSize + int64 (alloc .DataShards ) - 1 ) / int64 (alloc .DataShards )
@@ -61,18 +60,18 @@ var getDownloadCostCmd = &cobra.Command{
6160 )
6261
6362 if ! fflags .Changed ("allocation" ) {
64- log . Fatal ("missing required 'allocation' flag" )
63+ Fatal ("missing required 'allocation' flag" )
6564 }
6665
6766 allocID = cmd .Flag ("allocation" ).Value .String ()
6867 blocksPerMarker , err := cmd .Flags ().GetInt ("blocks-per-marker" )
6968
7069 if err != nil {
71- log . Fatal ("invalid blocks-per-marker value: " , err )
70+ Fatal ("invalid blocks-per-marker value: " , err )
7271 }
7372
7473 if blocksPerMarker <= 0 {
75- log . Fatal ("blocks-per-marker value cannot be <= 0" )
74+ Fatal ("blocks-per-marker value cannot be <= 0" )
7675 }
7776
7877 var (
@@ -83,24 +82,24 @@ var getDownloadCostCmd = &cobra.Command{
8382
8483 if fflags .Changed ("remotepath" ) {
8584 if remotePath , err = fflags .GetString ("remotepath" ); err != nil {
86- log . Fatal ("invalid 'remotepath' flag: " , err )
85+ Fatal ("invalid 'remotepath' flag: " , err )
8786 }
8887 }
8988
9089 if fflags .Changed ("authticket" ) {
9190 if authTicket , err = fflags .GetString ("authticket" ); err != nil {
92- log . Fatal ("invalid 'authticket' flag: " , err )
91+ Fatal ("invalid 'authticket' flag: " , err )
9392 }
9493 }
9594
9695 if fflags .Changed ("lookuphash" ) {
9796 if lookupHash , err = fflags .GetString ("lookuphash" ); err != nil {
98- log . Fatal ("invalid 'lookuphash' flag: " , err )
97+ Fatal ("invalid 'lookuphash' flag: " , err )
9998 }
10099 }
101100
102101 if remotePath == "" && authTicket == "" {
103- log . Fatal ("'remotepath' or 'authticket' flag required" )
102+ Fatal ("'remotepath' or 'authticket' flag required" )
104103 }
105104
106105 var (
@@ -113,11 +112,11 @@ var getDownloadCostCmd = &cobra.Command{
113112 // by remote path
114113
115114 if alloc , err = sdk .GetAllocation (allocID ); err != nil {
116- log . Fatal ("fetching the allocation: " , err )
115+ Fatal ("fetching the allocation: " , err )
117116 }
118117
119118 if meta , err = alloc .GetFileMeta (remotePath ); err != nil {
120- log . Fatal ("can't get file meta: " , err )
119+ Fatal ("can't get file meta: " , err )
121120 }
122121
123122 downloadCost (alloc , meta , blocksPerMarker )
@@ -128,19 +127,19 @@ var getDownloadCostCmd = &cobra.Command{
128127
129128 alloc , err = sdk .GetAllocationFromAuthTicket (authTicket )
130129 if err != nil {
131- log . Fatal ("can't get allocation object: " , err )
130+ Fatal ("can't get allocation object: " , err )
132131 }
133132 var at = sdk .InitAuthTicket (authTicket )
134133
135134 if lookupHash == "" {
136135 if lookupHash , err = at .GetLookupHash (); err != nil {
137- log . Fatal ("can't get lookup hash from auth ticket: " , err )
136+ Fatal ("can't get lookup hash from auth ticket: " , err )
138137 }
139138 }
140139
141140 meta , err = alloc .GetFileMetaFromAuthTicket (authTicket , lookupHash )
142141 if err != nil {
143- log . Fatal ("can't get file meta: " , err )
142+ Fatal ("can't get file meta: " , err )
144143 }
145144
146145 downloadCost (alloc , meta , blocksPerMarker )
0 commit comments