@@ -48,6 +48,22 @@ const TX_FEE_PARAMS = {
4848 avgTxSize : 1400 , // Average size based on mainnet data (Epoch 500+)
4949} ;
5050
51+ interface BlockTraffic {
52+ headers : number ;
53+ bodies : number ;
54+ }
55+
56+ interface VoteTraffic {
57+ votes : number ;
58+ }
59+
60+ interface TrafficBreakdown {
61+ ib : BlockTraffic ;
62+ eb : BlockTraffic ;
63+ rb : BlockTraffic ;
64+ votes : VoteTraffic ;
65+ }
66+
5167const LeiosTrafficCalculator : React . FC = ( ) => {
5268 const [ numPeers , setNumPeers ] = useState ( 20 ) ;
5369 const [ headerPropagationPercent , setHeaderPropagationPercent ] = useState (
@@ -79,7 +95,14 @@ const LeiosTrafficCalculator: React.FC = () => {
7995 return ( ) => window . removeEventListener ( "scroll" , handleScroll ) ;
8096 } , [ ] ) ;
8197
82- const calculateTraffic = ( ibRate : number ) => {
98+ const calculateTraffic = (
99+ ibRate : number ,
100+ ) : {
101+ traffic : TrafficBreakdown ;
102+ totalTraffic : number ;
103+ txFeeADA : number ;
104+ totalTxs : number ;
105+ } => {
83106 const ibCount = ibRate * SECONDS_PER_MONTH ;
84107 const stagesPerMonth = SECONDS_PER_MONTH / 20 ;
85108 const ebRate = 1.5 ; // EBs per pipeline
@@ -91,7 +114,7 @@ const LeiosTrafficCalculator: React.FC = () => {
91114 ) ;
92115 const bodyPeers = Math . round ( numPeers * ( bodyRequestPercent / 100 ) ) ;
93116
94- const traffic = {
117+ const traffic : TrafficBreakdown = {
95118 ib : {
96119 headers : ibCount * blockSizes . ib . header * headerPeers ,
97120 bodies : ibCount * blockSizes . ib . body *
@@ -107,14 +130,19 @@ const LeiosTrafficCalculator: React.FC = () => {
107130 headers : rbCount * blockSizes . rb . header * headerPeers ,
108131 bodies : rbCount * blockSizes . rb . body * bodyPeers ,
109132 } ,
110- votes : ebCount * blockSizes . vote . size *
111- blockSizes . vote . countPerPipeline * headerPeers ,
133+ votes : {
134+ votes : ebCount * blockSizes . vote . size *
135+ blockSizes . vote . countPerPipeline * headerPeers ,
136+ } ,
112137 } ;
113138
114139 const totalTraffic = Object . values ( traffic ) . reduce (
115- ( acc , block ) =>
116- acc + ( block . headers || 0 ) + ( block . bodies || 0 ) +
117- ( block . votes || 0 ) ,
140+ ( acc , block ) => {
141+ if ( "votes" in block ) {
142+ return acc + block . votes ;
143+ }
144+ return acc + block . headers + block . bodies ;
145+ } ,
118146 0 ,
119147 ) ;
120148
@@ -524,19 +552,18 @@ const LeiosTrafficCalculator: React.FC = () => {
524552 ) }
525553 </ li >
526554 < li >
527- EB Bodies:{ " " }
528- { ( ( SECONDS_PER_MONTH / 20 ) * 1.5 ) . toLocaleString ( ) }
529- { " " }
530- seconds × { blockSizes . eb . body } bytes × { 20 } { " " }
531- IBs/stage ×{ " " }
555+ EB Bodies: 1 IB/s × { blockSizes . eb . body } { " " }
556+ bytes × 1.5 EBs ×{ " " }
532557 { Math . round ( numPeers * ( bodyRequestPercent / 100 ) ) }
533558 { " " }
534- peers = { formatTraffic (
535- ( SECONDS_PER_MONTH / 20 ) * 1.5 *
536- blockSizes . eb . body * 20 *
559+ peers × { ( SECONDS_PER_MONTH / 20 ) . toLocaleString ( ) }
560+ { " " }
561+ stages = { formatTraffic (
562+ 1 * blockSizes . eb . body * 1.5 *
537563 Math . round (
538564 numPeers * ( bodyRequestPercent / 100 ) ,
539- ) ,
565+ ) *
566+ ( SECONDS_PER_MONTH / 20 ) ,
540567 ) }
541568 </ li >
542569 < li >
@@ -672,7 +699,9 @@ const LeiosTrafficCalculator: React.FC = () => {
672699 < td > { formatTraffic ( traffic . ib . bodies ) } </ td >
673700 < td > { formatTraffic ( traffic . eb . headers ) } </ td >
674701 < td > { formatTraffic ( traffic . eb . bodies ) } </ td >
675- < td > { formatTraffic ( traffic . votes ) } </ td >
702+ < td >
703+ { formatTraffic ( traffic . votes . votes ) }
704+ </ td >
676705 < td > { formatTraffic ( traffic . rb . headers ) } </ td >
677706 < td > { formatTraffic ( traffic . rb . bodies ) } </ td >
678707 < td > { formatTraffic ( totalTraffic ) } </ td >
@@ -699,7 +728,7 @@ const LeiosTrafficCalculator: React.FC = () => {
699728 </ div >
700729 </ div >
701730
702- < h3 > Monthly Cost by Cloud Provider ($)</ h3 >
731+ < h3 > Monthly Node Egress Cost by Cloud Provider ($)</ h3 >
703732 < div className = { styles . tableContainer } >
704733 < table className = { styles . table } >
705734 < thead >
0 commit comments