update
@ -11,6 +11,7 @@
|
||||
- Update `cmd/hidden_lake/helpers/traffic`: database now only store hashes, messages stores in memory
|
||||
- Update `cmd/hidden_lake/helpers/traffic`: rename "storage_enabled" -> "database_enabled"
|
||||
- Update `cmd/hidden_lake/helpers/traffic`: "messages_capacity" can be = 0
|
||||
- Update `pkg/storage/cache`: cache/lru/lru.go -> cache/lru.go
|
||||
|
||||
<!-- ... -->
|
||||
|
||||
|
||||
@ -99,7 +99,7 @@ On the basis of this characteristic, methods of possible application also begin
|
||||
|
||||
1. Due to the property of abstracting from network communications, the anonymous Hidden Lake network can be `integrated` into any other network (including a centralized one) where group communication is possible. In such a case, the HL software implementation provides for the essence of [adapters](https://github.com/number571/go-peer/tree/master/cmd/hidden_lake/adapters) that must be able to adapt to a specific execution environment, hiding and obscuring the generated parasitic traffic,
|
||||
2. Due to the `theoretically provable anonymity` and independence of nodes among themselves in choosing the period of packet generation, the network can be used in military affairs, ensuring not only the confidentiality of transmitted data, but also the confidentiality of metadata in the face of the activity of actions,
|
||||
3. The Hidden Lake network can be used as a `communication platform` for applications that are heterogeneous in nature. This is made possible by the go-peer protocol, which does not define any application use. As a result, you can create your own applications at several levels: either at the go-peer library level or at the HL services level ([example](https://github.com/number571/go-peer/tree/master/cmd/secpy_chat)),
|
||||
3. The Hidden Lake network can be used as a `communication platform` for applications that are heterogeneous in nature. This is made possible by the `GP/12` protocol, which does not define any application use. As a result, you can create your own applications at several levels: either at the go-peer library level or at the HL services level ([example](https://github.com/number571/go-peer/tree/master/cmd/secpy_chat)),
|
||||
4. Due to problems with scaling at the level of the `QB-problem` itself, the network is difficult to deploy in a global space, which nevertheless does not indicate a local field of action. Hidden Lake can protect `local networks` in a more efficient way due to the existence of small groups of participants that do not vary greatly in number. This may be a relevant solution in the context of the existence of critical areas of a local organization.
|
||||
|
||||
## Possible launch modes
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
>
|
||||
|
||||
<g>
|
||||
<rect x="20.000000" y="20.000000" width="988.000000" height="600.000000" style="fill: rgb(234, 246, 160);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
<rect x="20.000000" y="20.000000" width="988.000000" height="600.000000" style="fill: rgb(235, 246, 160);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
<text
|
||||
data-notex="1"
|
||||
@ -59,7 +59,7 @@
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="411.756749" y="41.600000" width="441.479966" height="310.944238" style="fill: rgb(120, 197, 100);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
<rect x="411.756749" y="41.600000" width="441.479966" height="310.944238" style="fill: rgb(121, 198, 101);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
<text
|
||||
data-notex="1"
|
||||
@ -215,7 +215,7 @@
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="419.756749" y="63.200000" width="180.003671" height="281.344238" style="fill: rgb(125, 199, 101);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
<rect x="419.756749" y="63.200000" width="180.003671" height="281.344238" style="fill: rgb(129, 201, 101);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
<text
|
||||
data-notex="1"
|
||||
@ -479,7 +479,7 @@
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="427.756749" y="84.800000" width="164.003671" height="133.984545" style="fill: rgb(159, 214, 105);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
<rect x="427.756749" y="84.800000" width="164.003671" height="139.367845" style="fill: rgb(169, 219, 108);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
<text
|
||||
data-notex="1"
|
||||
@ -492,12 +492,12 @@
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="427.756749" y="226.784545" width="164.003671" height="109.759693" style="fill: rgb(84, 179, 93);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
<rect x="427.756749" y="232.167845" width="164.003671" height="104.376393" style="fill: rgb(73, 173, 90);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
<text
|
||||
data-notex="1"
|
||||
text-anchor="start"
|
||||
transform="translate(435.756749,242.384545) scale(1.000000)"
|
||||
transform="translate(435.756749,247.767845) scale(1.000000)"
|
||||
style="font-family: Open Sans, verdana, arial, sans-serif !important; font-size: 12px; fill: rgb(0, 0, 0); fill-opacity: 1.00; white-space: pre;"
|
||||
data-math="N">pkg</text>
|
||||
|
||||
@ -1000,12 +1000,18 @@
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="519.303739" y="106.400000" width="64.456681" height="60.806864" style="fill: rgb(43, 158, 83);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
<rect x="568.779534" y="173.061044" width="14.980886" height="21.203886" style="fill: rgb(250, 143, 78);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
</g>
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="516.251794" y="106.400000" width="67.508626" height="58.661044" style="fill: rgb(43, 158, 83);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
<text
|
||||
data-notex="1"
|
||||
text-anchor="start"
|
||||
transform="translate(527.303739,122.000000) scale(0.841262)"
|
||||
transform="translate(524.251794,122.000000) scale(0.894247)"
|
||||
style="font-family: Open Sans, verdana, arial, sans-serif !important; font-size: 12px; fill: rgb(0, 0, 0); fill-opacity: 1.00; white-space: pre;"
|
||||
data-math="N">config</text>
|
||||
|
||||
@ -1013,18 +1019,18 @@
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="580.319891" y="175.206864" width="3.440529" height="35.577681" style="fill: rgb(80, 177, 92);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
<rect x="568.779534" y="202.264930" width="14.980886" height="13.902915" style="fill: rgb(80, 177, 92);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
</g>
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="435.756749" y="106.400000" width="75.546989" height="104.384545" style="fill: rgb(224, 242, 147);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
<rect x="435.756749" y="106.400000" width="72.495045" height="109.767845" style="fill: rgb(224, 242, 147);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
<text
|
||||
data-notex="1"
|
||||
text-anchor="start"
|
||||
transform="translate(443.756749,122.000000) scale(0.886116)"
|
||||
transform="translate(443.756749,122.000000) scale(0.840700)"
|
||||
style="font-family: Open Sans, verdana, arial, sans-serif !important; font-size: 12px; fill: rgb(0, 0, 0); fill-opacity: 1.00; white-space: pre;"
|
||||
data-math="N">handler</text>
|
||||
|
||||
@ -1032,12 +1038,12 @@
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="519.303739" y="175.206864" width="53.016153" height="35.577681" style="fill: rgb(94, 185, 96);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
<rect x="516.251794" y="173.061044" width="44.527740" height="43.106801" style="fill: rgb(94, 185, 96);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
<text
|
||||
data-notex="1"
|
||||
text-anchor="start"
|
||||
transform="translate(527.303739,190.806864) scale(0.550836)"
|
||||
transform="translate(524.251794,188.661044) scale(0.424520)"
|
||||
style="font-family: Open Sans, verdana, arial, sans-serif !important; font-size: 12px; fill: rgb(0, 0, 0); fill-opacity: 1.00; white-space: pre;"
|
||||
data-math="N">storage</text>
|
||||
|
||||
@ -1045,12 +1051,12 @@
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="435.756749" y="248.384545" width="85.602202" height="80.159693" style="fill: rgb(121, 197, 100);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
<rect x="435.756749" y="253.767845" width="82.612910" height="74.776393" style="fill: rgb(106, 191, 99);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
<text
|
||||
data-notex="1"
|
||||
text-anchor="start"
|
||||
transform="translate(443.756749,263.984545) scale(1.000000)"
|
||||
transform="translate(443.756749,269.367845) scale(1.000000)"
|
||||
style="font-family: Open Sans, verdana, arial, sans-serif !important; font-size: 12px; fill: rgb(0, 0, 0); fill-opacity: 1.00; white-space: pre;"
|
||||
data-math="N">app</text>
|
||||
|
||||
@ -1058,12 +1064,12 @@
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="529.358951" y="248.384545" width="54.401468" height="77.640845" style="fill: rgb(22, 146, 77);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
<rect x="526.369660" y="253.767845" width="57.390760" height="72.411353" style="fill: rgb(22, 146, 77);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
<text
|
||||
data-notex="1"
|
||||
text-anchor="start"
|
||||
transform="translate(537.358951,263.984545) scale(0.666692)"
|
||||
transform="translate(534.369660,269.367845) scale(0.718590)"
|
||||
style="font-family: Open Sans, verdana, arial, sans-serif !important; font-size: 12px; fill: rgb(0, 0, 0); fill-opacity: 1.00; white-space: pre;"
|
||||
data-math="N">client</text>
|
||||
|
||||
@ -1871,68 +1877,54 @@
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="527.303739" y="128.000000" width="37.165345" height="31.206864" style="fill: rgb(66, 169, 88);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
<rect x="524.251794" y="128.000000" width="39.606901" height="29.061044" style="fill: rgb(66, 169, 88);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
</g>
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="571.858694" y="128.000000" width="3.901725" height="25.972624" style="fill: rgb(0, 104, 55);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
</g>
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="471.916557" y="187.084160" width="19.683990" height="6.541843" style="fill: rgb(205, 234, 130);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
</g>
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="471.916557" y="160.770349" width="28.335236" height="18.313810" style="fill: rgb(175, 221, 111);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
</g>
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="499.600547" y="187.084160" width="0.651247" height="15.266948" style="fill: rgb(0, 104, 55);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
</g>
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="443.756749" y="128.000000" width="56.495045" height="24.770349" style="fill: rgb(248, 251, 178);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
</g>
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="471.916557" y="201.626002" width="19.683990" height="6.541843" style="fill: rgb(205, 234, 130);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
</g>
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="443.756749" y="160.770349" width="20.159808" height="47.397495" style="fill: rgb(250, 253, 182);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
<text
|
||||
data-notex="1"
|
||||
text-anchor="start"
|
||||
transform="translate(535.303739,143.600000) scale(0.244969)"
|
||||
style="font-family: Open Sans, verdana, arial, sans-serif !important; font-size: 12px; fill: rgb(0, 0, 0); fill-opacity: 1.00; white-space: pre;"
|
||||
data-math="N">config.go</text>
|
||||
|
||||
</g>
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="572.469083" y="128.000000" width="3.291336" height="27.939625" style="fill: rgb(0, 104, 55);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
</g>
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="475.841569" y="181.480281" width="19.018796" height="6.652132" style="fill: rgb(205, 234, 130);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
</g>
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="443.756749" y="181.480281" width="24.084820" height="21.304264" style="fill: rgb(175, 221, 111);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
</g>
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="502.860365" y="181.480281" width="0.443374" height="15.443411" style="fill: rgb(0, 104, 55);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
</g>
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="443.756749" y="128.000000" width="30.862651" height="45.480281" style="fill: rgb(248, 251, 178);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
<text
|
||||
data-notex="1"
|
||||
text-anchor="start"
|
||||
transform="translate(451.756749,143.600000) scale(0.154819)"
|
||||
style="font-family: Open Sans, verdana, arial, sans-serif !important; font-size: 12px; fill: rgb(0, 0, 0); fill-opacity: 1.00; white-space: pre;"
|
||||
data-math="N">message.go</text>
|
||||
|
||||
</g>
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="475.841569" y="196.132413" width="19.018796" height="6.652132" style="fill: rgb(205, 234, 130);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
</g>
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="482.619401" y="128.000000" width="20.684338" height="45.480281" style="fill: rgb(250, 253, 182);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
<text
|
||||
data-notex="1"
|
||||
text-anchor="start"
|
||||
transform="translate(490.619401,143.600000) scale(0.034854)"
|
||||
transform="translate(451.756749,176.370349) scale(0.030951)"
|
||||
style="font-family: Open Sans, verdana, arial, sans-serif !important; font-size: 12px; fill: rgb(0, 0, 0); fill-opacity: 1.00; white-space: pre;"
|
||||
data-math="N">service_tcp.go</text>
|
||||
|
||||
@ -1940,18 +1932,18 @@
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="527.303739" y="196.806864" width="35.609398" height="5.977681" style="fill: rgb(98, 187, 98);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
<rect x="524.251794" y="194.661044" width="27.386248" height="13.506801" style="fill: rgb(98, 187, 98);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
</g>
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="443.756749" y="269.984545" width="42.256664" height="50.559693" style="fill: rgb(144, 208, 103);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
<rect x="443.756749" y="275.367845" width="44.305958" height="45.176393" style="fill: rgb(144, 208, 103);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
<text
|
||||
data-notex="1"
|
||||
text-anchor="start"
|
||||
transform="translate(451.756749,285.584545) scale(0.455845)"
|
||||
transform="translate(451.756749,290.967845) scale(0.491423)"
|
||||
style="font-family: Open Sans, verdana, arial, sans-serif !important; font-size: 12px; fill: rgb(0, 0, 0); fill-opacity: 1.00; white-space: pre;"
|
||||
data-math="N">app.go</text>
|
||||
|
||||
@ -1959,43 +1951,31 @@
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="494.013413" y="293.724961" width="6.915748" height="9.409639" style="fill: rgb(80, 177, 92);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
<rect x="496.062707" y="302.872876" width="14.306953" height="3.002012" style="fill: rgb(80, 177, 92);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
</g>
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="494.013413" y="269.984545" width="6.584287" height="15.740416" style="fill: rgb(50, 161, 84);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
<rect x="496.062707" y="275.367845" width="14.306953" height="6.669350" style="fill: rgb(50, 161, 84);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
</g>
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="508.597700" y="269.984545" width="4.761251" height="15.740416" style="fill: rgb(0, 104, 55);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
<rect x="496.062707" y="290.037195" width="14.306953" height="4.835681" style="fill: rgb(0, 104, 55);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
</g>
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="508.929161" y="293.724961" width="4.429790" height="9.409639" style="fill: rgb(0, 104, 55);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
<rect x="534.369660" y="306.004102" width="35.902898" height="12.175096" style="fill: rgb(0, 104, 55);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
</g>
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="494.013413" y="311.134599" width="4.429790" height="9.409639" style="fill: rgb(244, 109, 67);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
</g>
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="537.358951" y="303.773878" width="33.245750" height="14.251512" style="fill: rgb(0, 104, 55);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
</g>
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="537.358951" y="269.984545" width="38.401468" height="25.789333" style="fill: rgb(67, 169, 88);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
<rect x="534.369660" y="275.367845" width="41.390760" height="22.636257" style="fill: rgb(67, 169, 88);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
</g>
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 73 KiB |
@ -13,7 +13,7 @@ import (
|
||||
"github.com/number571/go-peer/pkg/logger"
|
||||
net_message "github.com/number571/go-peer/pkg/network/message"
|
||||
"github.com/number571/go-peer/pkg/state"
|
||||
"github.com/number571/go-peer/pkg/storage/cache/lru"
|
||||
"github.com/number571/go-peer/pkg/storage/cache"
|
||||
"github.com/number571/go-peer/pkg/types"
|
||||
)
|
||||
|
||||
@ -52,7 +52,7 @@ func (p *sApp) Run(pCtx context.Context) error {
|
||||
adapted.NewAdaptedConsumer(
|
||||
p.fPostID,
|
||||
p.fSettings,
|
||||
lru.NewLRUCache(1<<10),
|
||||
cache.NewLRUCache(1<<10),
|
||||
),
|
||||
p.fStdfLogger,
|
||||
hlt_client.NewClient(
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
<img src="_images/hlt_logo.png" alt="hlt_logo.png"/>
|
||||
|
||||
The `Hidden Lake Traffic` is an application that saves traffic passed through HLS. The saved traffic can be used by other applications when they were offline. HLT provides an API for loading and unloading messages. Messages are stored in the database based on the "ring" structure. Thus, new messages will overwrite the old ones after some time. Can act as a TURN server for HLS's or other P2P nodes with go-peer protocol.
|
||||
The `Hidden Lake Traffic` is an application that saves traffic passed through HLS. The saved traffic can be used by other applications when they were offline. HLT provides an API for loading and unloading messages. Messages are stored in the inmemory database based on the "ring" structure. Thus, new messages will overwrite the old ones after some time. Can act as a TURN server for HLS's or other P2P nodes with GP/12 protocol.
|
||||
|
||||
> More information about HLT in the [habr.com/ru/post/717184](https://habr.com/ru/post/717184/ "Habr HLT")
|
||||
|
||||
|
||||
12
cmd/hidden_lake/helpers/traffic/internal/cache/lru_cache.go
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"github.com/number571/go-peer/pkg/storage/cache"
|
||||
)
|
||||
|
||||
func NewLRUCache(pCapacity uint64) cache.ILRUCache {
|
||||
if pCapacity == 0 {
|
||||
return newVoidLRUCache()
|
||||
}
|
||||
return cache.NewLRUCache(pCapacity)
|
||||
}
|
||||
@ -1,16 +1,14 @@
|
||||
package app
|
||||
package cache
|
||||
|
||||
import (
|
||||
"github.com/number571/go-peer/pkg/storage/cache/lru"
|
||||
"github.com/number571/go-peer/pkg/storage/cache"
|
||||
)
|
||||
|
||||
var (
|
||||
_ lru.ILRUCache = &sVoidLRUCache{}
|
||||
)
|
||||
var _ cache.ILRUCache = &sVoidLRUCache{}
|
||||
|
||||
type sVoidLRUCache struct{}
|
||||
|
||||
func newVoidLRUCache() lru.ILRUCache { return &sVoidLRUCache{} }
|
||||
func newVoidLRUCache() cache.ILRUCache { return &sVoidLRUCache{} }
|
||||
|
||||
func (p *sVoidLRUCache) GetIndex() uint64 { return 0 }
|
||||
func (p *sVoidLRUCache) GetKey(_ uint64) ([]byte, bool) { return nil, false }
|
||||
@ -22,7 +22,7 @@ import (
|
||||
"github.com/number571/go-peer/pkg/network/conn"
|
||||
"github.com/number571/go-peer/pkg/network/connkeeper"
|
||||
net_message "github.com/number571/go-peer/pkg/network/message"
|
||||
"github.com/number571/go-peer/pkg/storage/cache/lru"
|
||||
"github.com/number571/go-peer/pkg/storage/cache"
|
||||
"github.com/number571/go-peer/pkg/storage/database"
|
||||
"github.com/number571/go-peer/pkg/types"
|
||||
testutils "github.com/number571/go-peer/test/utils"
|
||||
@ -68,7 +68,7 @@ func testAllRun(addr string) (*http.Server, context.CancelFunc, storage.IMessage
|
||||
FWorkSizeBits: testutils.TCWorkSize,
|
||||
}),
|
||||
db,
|
||||
lru.NewLRUCache(testutils.TCCapacity),
|
||||
cache.NewLRUCache(testutils.TCCapacity),
|
||||
)
|
||||
|
||||
srv, _, cancel := testRunService(stg, addr, "")
|
||||
@ -185,6 +185,6 @@ func testNewNetworkNode(addr string) network.INode {
|
||||
FWriteTimeout: time.Minute,
|
||||
}),
|
||||
}),
|
||||
lru.NewLRUCache(testutils.TCCapacity),
|
||||
cache.NewLRUCache(testutils.TCCapacity),
|
||||
)
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/number571/go-peer/pkg/crypto/hashing"
|
||||
net_message "github.com/number571/go-peer/pkg/network/message"
|
||||
"github.com/number571/go-peer/pkg/storage/cache/lru"
|
||||
"github.com/number571/go-peer/pkg/storage/cache"
|
||||
"github.com/number571/go-peer/pkg/storage/database"
|
||||
"github.com/number571/go-peer/pkg/utils"
|
||||
)
|
||||
@ -17,13 +17,13 @@ var (
|
||||
type sMessageStorage struct {
|
||||
fSettings net_message.ISettings
|
||||
fDatabase database.IKVDatabase
|
||||
fLRUCache lru.ILRUCache
|
||||
fLRUCache cache.ILRUCache
|
||||
}
|
||||
|
||||
func NewMessageStorage(
|
||||
pSettings net_message.ISettings,
|
||||
pDatabase database.IKVDatabase,
|
||||
pLRUCache lru.ILRUCache,
|
||||
pLRUCache cache.ILRUCache,
|
||||
) IMessageStorage {
|
||||
return &sMessageStorage{
|
||||
fSettings: pSettings,
|
||||
@ -40,7 +40,7 @@ func (p *sMessageStorage) GetKVDatabase() database.IKVDatabase {
|
||||
return p.fDatabase
|
||||
}
|
||||
|
||||
func (p *sMessageStorage) GetLRUCache() lru.ILRUCache {
|
||||
func (p *sMessageStorage) GetLRUCache() cache.ILRUCache {
|
||||
return p.fLRUCache
|
||||
}
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ import (
|
||||
"github.com/number571/go-peer/pkg/crypto/hashing"
|
||||
net_message "github.com/number571/go-peer/pkg/network/message"
|
||||
"github.com/number571/go-peer/pkg/payload"
|
||||
"github.com/number571/go-peer/pkg/storage/cache/lru"
|
||||
"github.com/number571/go-peer/pkg/storage/cache"
|
||||
testutils "github.com/number571/go-peer/test/utils"
|
||||
)
|
||||
|
||||
@ -37,7 +37,7 @@ func TestStorageLoad(t *testing.T) {
|
||||
FNetworkKey: testutils.TCNetworkKey,
|
||||
}),
|
||||
hlt_database.NewVoidKVDatabase(),
|
||||
lru.NewLRUCache(testutils.TCCapacity),
|
||||
cache.NewLRUCache(testutils.TCCapacity),
|
||||
)
|
||||
|
||||
if _, err := db.Load([]byte("abc")); err == nil {
|
||||
@ -68,7 +68,7 @@ func TestStorageHashes(t *testing.T) {
|
||||
FNetworkKey: testutils.TCNetworkKey,
|
||||
}),
|
||||
hlt_database.NewVoidKVDatabase(),
|
||||
lru.NewLRUCache(messagesCapacity),
|
||||
cache.NewLRUCache(messagesCapacity),
|
||||
)
|
||||
|
||||
cl := client.NewClient(
|
||||
@ -123,7 +123,7 @@ func TestStoragePush(t *testing.T) {
|
||||
FNetworkKey: testutils.TCNetworkKey,
|
||||
}),
|
||||
hlt_database.NewVoidKVDatabase(),
|
||||
lru.NewLRUCache(1),
|
||||
cache.NewLRUCache(1),
|
||||
)
|
||||
|
||||
clTest := client.NewClient(
|
||||
@ -196,7 +196,7 @@ func TestStorage(t *testing.T) {
|
||||
FNetworkKey: testutils.TCNetworkKey,
|
||||
}),
|
||||
hlt_database.NewVoidKVDatabase(),
|
||||
lru.NewLRUCache(4),
|
||||
cache.NewLRUCache(4),
|
||||
)
|
||||
|
||||
cl := client.NewClient(
|
||||
|
||||
@ -2,14 +2,14 @@ package storage
|
||||
|
||||
import (
|
||||
net_message "github.com/number571/go-peer/pkg/network/message"
|
||||
"github.com/number571/go-peer/pkg/storage/cache/lru"
|
||||
"github.com/number571/go-peer/pkg/storage/cache"
|
||||
"github.com/number571/go-peer/pkg/storage/database"
|
||||
)
|
||||
|
||||
type IMessageStorage interface {
|
||||
GetSettings() net_message.ISettings
|
||||
GetKVDatabase() database.IKVDatabase
|
||||
GetLRUCache() lru.ILRUCache
|
||||
GetLRUCache() cache.ILRUCache
|
||||
|
||||
Pointer() uint64
|
||||
Push(net_message.IMessage) error
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"github.com/number571/go-peer/cmd/hidden_lake/helpers/traffic/internal/cache"
|
||||
"github.com/number571/go-peer/cmd/hidden_lake/helpers/traffic/internal/handler"
|
||||
"github.com/number571/go-peer/cmd/hidden_lake/helpers/traffic/internal/storage"
|
||||
"github.com/number571/go-peer/pkg/network"
|
||||
"github.com/number571/go-peer/pkg/network/conn"
|
||||
"github.com/number571/go-peer/pkg/storage/cache/lru"
|
||||
|
||||
hls_settings "github.com/number571/go-peer/cmd/hidden_lake/service/pkg/settings"
|
||||
)
|
||||
@ -27,7 +27,7 @@ func (p *sApp) initNetworkNode(pStorage storage.IMessageStorage) {
|
||||
FWriteTimeout: hls_settings.CNetworkWriteTimeout,
|
||||
}),
|
||||
}),
|
||||
lru.NewLRUCache(hls_settings.CNetworkQueueCapacity),
|
||||
cache.NewLRUCache(hls_settings.CNetworkQueueCapacity),
|
||||
).HandleFunc(
|
||||
hls_settings.CNetworkMask,
|
||||
handler.HandleServiceTCP(p.fConfig, pStorage, p.fAnonLogger),
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"github.com/number571/go-peer/cmd/hidden_lake/helpers/traffic/internal/cache"
|
||||
"github.com/number571/go-peer/cmd/hidden_lake/helpers/traffic/internal/storage"
|
||||
"github.com/number571/go-peer/pkg/storage/cache/lru"
|
||||
"github.com/number571/go-peer/pkg/storage/database"
|
||||
)
|
||||
|
||||
func (p *sApp) initStorage(pDatabase database.IKVDatabase) {
|
||||
cfgSettings := p.fConfig.GetSettings()
|
||||
lruCache := newVoidLRUCache()
|
||||
if mcap := cfgSettings.GetMessagesCapacity(); mcap != 0 {
|
||||
lruCache = lru.NewLRUCache(mcap)
|
||||
}
|
||||
p.fStorage = storage.NewMessageStorage(cfgSettings, pDatabase, lruCache)
|
||||
p.fStorage = storage.NewMessageStorage(
|
||||
cfgSettings,
|
||||
pDatabase,
|
||||
cache.NewLRUCache(cfgSettings.GetMessagesCapacity()),
|
||||
)
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ import (
|
||||
"github.com/number571/go-peer/pkg/network/anonymity/queue"
|
||||
"github.com/number571/go-peer/pkg/network/conn"
|
||||
net_message "github.com/number571/go-peer/pkg/network/message"
|
||||
"github.com/number571/go-peer/pkg/storage/cache/lru"
|
||||
"github.com/number571/go-peer/pkg/storage/cache"
|
||||
"github.com/number571/go-peer/pkg/storage/database"
|
||||
"github.com/number571/go-peer/pkg/types"
|
||||
testutils "github.com/number571/go-peer/test/utils"
|
||||
@ -251,6 +251,6 @@ func testNewNetworkNode(addr string) network.INode {
|
||||
FWriteTimeout: time.Minute,
|
||||
}),
|
||||
}),
|
||||
lru.NewLRUCache(testutils.TCCapacity),
|
||||
cache.NewLRUCache(testutils.TCCapacity),
|
||||
)
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ import (
|
||||
"github.com/number571/go-peer/pkg/network/anonymity"
|
||||
"github.com/number571/go-peer/pkg/network/anonymity/queue"
|
||||
"github.com/number571/go-peer/pkg/network/conn"
|
||||
"github.com/number571/go-peer/pkg/storage/cache/lru"
|
||||
"github.com/number571/go-peer/pkg/storage/cache"
|
||||
"github.com/number571/go-peer/pkg/storage/database"
|
||||
"github.com/number571/go-peer/pkg/utils"
|
||||
|
||||
@ -85,7 +85,7 @@ func (p *sApp) initAnonNode() error {
|
||||
FWriteTimeout: hls_settings.CNetworkWriteTimeout,
|
||||
}),
|
||||
}),
|
||||
lru.NewLRUCache(hls_settings.CNetworkQueueCapacity),
|
||||
cache.NewLRUCache(hls_settings.CNetworkQueueCapacity),
|
||||
),
|
||||
queue.NewQBProblemProcessor(
|
||||
queue.NewSettings(&queue.SSettings{
|
||||
|
||||
@ -19,7 +19,7 @@ import (
|
||||
"github.com/number571/go-peer/pkg/network"
|
||||
"github.com/number571/go-peer/pkg/network/anonymity/queue"
|
||||
"github.com/number571/go-peer/pkg/payload"
|
||||
"github.com/number571/go-peer/pkg/storage/cache/lru"
|
||||
"github.com/number571/go-peer/pkg/storage/cache"
|
||||
"github.com/number571/go-peer/pkg/storage/database"
|
||||
testutils "github.com/number571/go-peer/test/utils"
|
||||
|
||||
@ -707,7 +707,7 @@ func testNewNode(timeWait time.Duration, addr string, typeDB, numDB int) (INode,
|
||||
FWriteTimeout: time.Minute,
|
||||
}),
|
||||
}),
|
||||
lru.NewLRUCache(testutils.TCCapacity),
|
||||
cache.NewLRUCache(testutils.TCCapacity),
|
||||
),
|
||||
queue.NewQBProblemProcessor(
|
||||
queue.NewSettings(&queue.SSettings{
|
||||
|
||||
@ -15,7 +15,7 @@ import (
|
||||
"github.com/number571/go-peer/pkg/network/anonymity/queue"
|
||||
"github.com/number571/go-peer/pkg/network/conn"
|
||||
net_message "github.com/number571/go-peer/pkg/network/message"
|
||||
"github.com/number571/go-peer/pkg/storage/cache/lru"
|
||||
"github.com/number571/go-peer/pkg/storage/cache"
|
||||
"github.com/number571/go-peer/pkg/storage/database"
|
||||
)
|
||||
|
||||
@ -90,7 +90,7 @@ func newNode(serviceName, address string) anonymity.INode {
|
||||
FWriteTimeout: time.Minute,
|
||||
}),
|
||||
}),
|
||||
lru.NewLRUCache(1024),
|
||||
cache.NewLRUCache(1024),
|
||||
),
|
||||
queue.NewQBProblemProcessor(
|
||||
queue.NewSettings(&queue.SSettings{
|
||||
|
||||
@ -15,7 +15,7 @@ import (
|
||||
"github.com/number571/go-peer/pkg/network/anonymity/queue"
|
||||
"github.com/number571/go-peer/pkg/network/conn"
|
||||
net_message "github.com/number571/go-peer/pkg/network/message"
|
||||
"github.com/number571/go-peer/pkg/storage/cache/lru"
|
||||
"github.com/number571/go-peer/pkg/storage/cache"
|
||||
"github.com/number571/go-peer/pkg/storage/database"
|
||||
)
|
||||
|
||||
@ -90,7 +90,7 @@ func newNode(serviceName, address string) anonymity.INode {
|
||||
FWriteTimeout: time.Minute,
|
||||
}),
|
||||
}),
|
||||
lru.NewLRUCache(1024),
|
||||
cache.NewLRUCache(1024),
|
||||
),
|
||||
queue.NewQBProblemProcessor(
|
||||
queue.NewSettings(&queue.SSettings{
|
||||
|
||||
@ -11,7 +11,7 @@ import (
|
||||
"github.com/number571/go-peer/pkg/network"
|
||||
"github.com/number571/go-peer/pkg/network/conn"
|
||||
"github.com/number571/go-peer/pkg/network/message"
|
||||
"github.com/number571/go-peer/pkg/storage/cache/lru"
|
||||
"github.com/number571/go-peer/pkg/storage/cache"
|
||||
testutils "github.com/number571/go-peer/test/utils"
|
||||
)
|
||||
|
||||
@ -142,7 +142,7 @@ func newTestConnKeeper(pDuration time.Duration) IConnKeeper {
|
||||
FWriteTimeout: time.Minute,
|
||||
}),
|
||||
}),
|
||||
lru.NewLRUCache(testutils.TCCapacity),
|
||||
cache.NewLRUCache(testutils.TCCapacity),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/number571/go-peer/pkg/network"
|
||||
"github.com/number571/go-peer/pkg/network/conn"
|
||||
"github.com/number571/go-peer/pkg/storage/cache/lru"
|
||||
"github.com/number571/go-peer/pkg/storage/cache"
|
||||
)
|
||||
|
||||
func newNode(serviceAddress string) network.INode {
|
||||
@ -23,6 +23,6 @@ func newNode(serviceAddress string) network.INode {
|
||||
FWriteTimeout: time.Minute,
|
||||
FReadTimeout: time.Minute,
|
||||
}),
|
||||
lru.NewLRUCache(1<<10),
|
||||
cache.NewLRUCache(1<<10),
|
||||
)
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/number571/go-peer/pkg/network"
|
||||
"github.com/number571/go-peer/pkg/network/conn"
|
||||
"github.com/number571/go-peer/pkg/storage/cache/lru"
|
||||
"github.com/number571/go-peer/pkg/storage/cache"
|
||||
)
|
||||
|
||||
func newNode(serviceAddress string) network.INode {
|
||||
@ -17,7 +17,7 @@ func newNode(serviceAddress string) network.INode {
|
||||
FWriteTimeout: time.Minute,
|
||||
FReadTimeout: time.Minute,
|
||||
}),
|
||||
lru.NewLRUCache(1<<10),
|
||||
cache.NewLRUCache(1<<10),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/number571/go-peer/pkg/network"
|
||||
"github.com/number571/go-peer/pkg/network/conn"
|
||||
"github.com/number571/go-peer/pkg/storage/cache/lru"
|
||||
"github.com/number571/go-peer/pkg/storage/cache"
|
||||
)
|
||||
|
||||
func newNode(serviceAddress string) network.INode {
|
||||
@ -23,6 +23,6 @@ func newNode(serviceAddress string) network.INode {
|
||||
FWriteTimeout: time.Minute,
|
||||
FReadTimeout: time.Minute,
|
||||
}),
|
||||
lru.NewLRUCache(1<<10),
|
||||
cache.NewLRUCache(1<<10),
|
||||
)
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ import (
|
||||
"github.com/number571/go-peer/pkg/network/conn"
|
||||
"github.com/number571/go-peer/pkg/network/message"
|
||||
"github.com/number571/go-peer/pkg/payload"
|
||||
"github.com/number571/go-peer/pkg/storage/cache/lru"
|
||||
"github.com/number571/go-peer/pkg/storage/cache"
|
||||
testutils "github.com/number571/go-peer/test/utils"
|
||||
)
|
||||
|
||||
@ -433,7 +433,7 @@ func newTestNode(pAddr string, pMaxConns uint64) INode {
|
||||
FWriteTimeout: timeout,
|
||||
}),
|
||||
}),
|
||||
lru.NewLRUCache(testutils.TCCapacity),
|
||||
cache.NewLRUCache(testutils.TCCapacity),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
80
pkg/storage/cache/cache_test.go
vendored
@ -1,5 +1,81 @@
|
||||
package cache
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
func TestNothing(_ *testing.T) {}
|
||||
"github.com/number571/go-peer/pkg/encoding"
|
||||
)
|
||||
|
||||
func TestLRUCache(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
lruCache := NewLRUCache(3)
|
||||
|
||||
if _, ok := lruCache.Get([]byte("unknown-key")); ok {
|
||||
t.Error("success load unknown key")
|
||||
return
|
||||
}
|
||||
|
||||
for i := 0; i < 3; i++ {
|
||||
key := encoding.Uint64ToBytes(uint64(i))
|
||||
if ok := lruCache.Set(key[:], []byte(fmt.Sprintf("_%d_", i))); !ok {
|
||||
t.Errorf("failed push %d", i)
|
||||
return
|
||||
}
|
||||
if lruCache.GetIndex() != uint64((i+1)%3) {
|
||||
t.Error("got invalid index")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
for i := 0; i < 3; i++ {
|
||||
key := encoding.Uint64ToBytes(uint64(i))
|
||||
val, ok := lruCache.Get(
|
||||
key[:],
|
||||
)
|
||||
if !ok {
|
||||
t.Errorf("failed load %d", i)
|
||||
return
|
||||
}
|
||||
if !bytes.Equal(val, []byte(fmt.Sprintf("_%d_", i))) {
|
||||
t.Errorf("value is incorrect %d", i)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
for i := uint64(0); ; i++ {
|
||||
k, ok := lruCache.GetKey(i)
|
||||
if !ok {
|
||||
break
|
||||
}
|
||||
key := encoding.Uint64ToBytes(i)
|
||||
if !bytes.Equal(k, key[:]) {
|
||||
t.Error("got incorrect key")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
key1 := encoding.Uint64ToBytes(1)
|
||||
if ok := lruCache.Set(key1[:], []byte(fmt.Sprintf("_%d_", 1))); ok {
|
||||
t.Error("success push already exist value")
|
||||
return
|
||||
}
|
||||
|
||||
// start cycle of queue
|
||||
i := uint64(4)
|
||||
key2 := encoding.Uint64ToBytes(i)
|
||||
if ok := lruCache.Set(key2[:], []byte(fmt.Sprintf("_%d_", i))); !ok {
|
||||
t.Errorf("failed push %d", i)
|
||||
return
|
||||
}
|
||||
|
||||
// try load init value
|
||||
i = 0
|
||||
key3 := encoding.Uint64ToBytes(i)
|
||||
if _, ok := lruCache.Get(key3[:]); ok {
|
||||
t.Errorf("success load rewrited value %d", i)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
2
pkg/storage/cache/doc.go
vendored
@ -1,2 +1,2 @@
|
||||
// Package cache allows you to store values in the temporary storage.
|
||||
// Package cache allows you to store values in the inmemory storage.
|
||||
package cache
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package lru
|
||||
package cache
|
||||
|
||||
import (
|
||||
"sync"
|
||||
4
pkg/storage/cache/lru/doc.go
vendored
@ -1,4 +0,0 @@
|
||||
// Package lru allows you to store values in a queue and compare their existence.
|
||||
//
|
||||
// Used as a temporary cache storage (least recently used).
|
||||
package lru
|
||||
81
pkg/storage/cache/lru/lru_test.go
vendored
@ -1,81 +0,0 @@
|
||||
package lru
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/number571/go-peer/pkg/encoding"
|
||||
)
|
||||
|
||||
func TestLRUCache(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
lruCache := NewLRUCache(3)
|
||||
|
||||
if _, ok := lruCache.Get([]byte("unknown-key")); ok {
|
||||
t.Error("success load unknown key")
|
||||
return
|
||||
}
|
||||
|
||||
for i := 0; i < 3; i++ {
|
||||
key := encoding.Uint64ToBytes(uint64(i))
|
||||
if ok := lruCache.Set(key[:], []byte(fmt.Sprintf("_%d_", i))); !ok {
|
||||
t.Errorf("failed push %d", i)
|
||||
return
|
||||
}
|
||||
if lruCache.GetIndex() != uint64((i+1)%3) {
|
||||
t.Error("got invalid index")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
for i := 0; i < 3; i++ {
|
||||
key := encoding.Uint64ToBytes(uint64(i))
|
||||
val, ok := lruCache.Get(
|
||||
key[:],
|
||||
)
|
||||
if !ok {
|
||||
t.Errorf("failed load %d", i)
|
||||
return
|
||||
}
|
||||
if !bytes.Equal(val, []byte(fmt.Sprintf("_%d_", i))) {
|
||||
t.Errorf("value is incorrect %d", i)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
for i := uint64(0); ; i++ {
|
||||
k, ok := lruCache.GetKey(i)
|
||||
if !ok {
|
||||
break
|
||||
}
|
||||
key := encoding.Uint64ToBytes(i)
|
||||
if !bytes.Equal(k, key[:]) {
|
||||
t.Error("got incorrect key")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
key1 := encoding.Uint64ToBytes(1)
|
||||
if ok := lruCache.Set(key1[:], []byte(fmt.Sprintf("_%d_", 1))); ok {
|
||||
t.Error("success push already exist value")
|
||||
return
|
||||
}
|
||||
|
||||
// start cycle of queue
|
||||
i := uint64(4)
|
||||
key2 := encoding.Uint64ToBytes(i)
|
||||
if ok := lruCache.Set(key2[:], []byte(fmt.Sprintf("_%d_", i))); !ok {
|
||||
t.Errorf("failed push %d", i)
|
||||
return
|
||||
}
|
||||
|
||||
// try load init value
|
||||
i = 0
|
||||
key3 := encoding.Uint64ToBytes(i)
|
||||
if _, ok := lruCache.Get(key3[:]); ok {
|
||||
t.Errorf("success load rewrited value %d", i)
|
||||
return
|
||||
}
|
||||
}
|
||||
10
pkg/storage/cache/lru/types.go
vendored
@ -1,10 +0,0 @@
|
||||
package lru
|
||||
|
||||
import "github.com/number571/go-peer/pkg/storage/cache"
|
||||
|
||||
type ILRUCache interface {
|
||||
cache.ICache
|
||||
|
||||
GetIndex() uint64
|
||||
GetKey(i uint64) ([]byte, bool)
|
||||
}
|
||||
7
pkg/storage/cache/types.go
vendored
@ -1,5 +1,12 @@
|
||||
package cache
|
||||
|
||||
type ILRUCache interface {
|
||||
ICache
|
||||
|
||||
GetIndex() uint64
|
||||
GetKey(i uint64) ([]byte, bool)
|
||||
}
|
||||
|
||||
type ICache interface {
|
||||
ICacheSetter
|
||||
ICacheGetter
|
||||
|
||||
@ -1 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="96" height="20" role="img" aria-label="code lines: 43129"><title>code lines: 43129</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="96" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="57" height="20" fill="#555"/><rect x="57" width="40" height="20" fill="#4682b4"/><rect width="96" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="295" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="510">code lines</text><text x="295" y="140" transform="scale(.1)" fill="#fff" textLength="510">code lines</text><text aria-hidden="true" x="770" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="320">43129</text><text x="770" y="140" transform="scale(.1)" fill="#fff" textLength="320">43129</text></g></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="96" height="20" role="img" aria-label="code lines: 43145"><title>code lines: 43145</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="96" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="57" height="20" fill="#555"/><rect x="57" width="40" height="20" fill="#4682b4"/><rect width="96" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="295" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="510">code lines</text><text x="295" y="140" transform="scale(.1)" fill="#fff" textLength="510">code lines</text><text aria-hidden="true" x="770" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="320">43145</text><text x="770" y="140" transform="scale(.1)" fill="#fff" textLength="320">43145</text></g></svg>
|
||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
@ -1 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="96" height="20" role="img" aria-label="coverage: 97%"><title>coverage: 97%</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="96" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="61" height="20" fill="#555"/><rect x="61" width="35" height="20" fill="#97ca00"/><rect width="96" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="315" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="510">coverage</text><text x="315" y="140" transform="scale(.1)" fill="#fff" textLength="510">coverage</text><text aria-hidden="true" x="775" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">97%</text><text x="775" y="140" transform="scale(.1)" fill="#fff" textLength="250">97%</text></g></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="96" height="20" role="img" aria-label="coverage: 98%"><title>coverage: 98%</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="96" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="61" height="20" fill="#555"/><rect x="61" width="35" height="20" fill="#97ca00"/><rect width="96" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="315" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="510">coverage</text><text x="315" y="140" transform="scale(.1)" fill="#fff" textLength="510">coverage</text><text aria-hidden="true" x="775" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">98%</text><text x="775" y="140" transform="scale(.1)" fill="#fff" textLength="250">98%</text></g></svg>
|
||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
29163
test/result/coverage.out
@ -7,7 +7,7 @@
|
||||
>
|
||||
|
||||
<g>
|
||||
<rect x="20.000000" y="20.000000" width="988.000000" height="600.000000" style="fill: rgb(3, 114, 60);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
<rect x="20.000000" y="20.000000" width="988.000000" height="600.000000" style="fill: rgb(3, 113, 60);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
<text
|
||||
data-notex="1"
|
||||
@ -214,7 +214,7 @@
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="36.000000" y="63.200000" width="448.665368" height="540.800000" style="fill: rgb(4, 115, 61);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
<rect x="36.000000" y="63.200000" width="448.665368" height="540.800000" style="fill: rgb(4, 114, 60);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
<text
|
||||
data-notex="1"
|
||||
@ -569,7 +569,7 @@
|
||||
|
||||
|
||||
<g>
|
||||
<rect x="44.000000" y="332.764142" width="170.612886" height="263.235858" style="fill: rgb(16, 135, 71);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
<rect x="44.000000" y="332.764142" width="170.612886" height="263.235858" style="fill: rgb(14, 132, 69);opacity:1;fill-opacity:1.00;stroke:rgb(128,128,128);stroke-width:1px;stroke-opacity:1.00;" />
|
||||
|
||||
<text
|
||||
data-notex="1"
|
||||
@ -652,9 +652,9 @@
|
||||
<text
|
||||
data-notex="1"
|
||||
text-anchor="start"
|
||||
transform="translate(678.553909,292.480000) scale(0.103996)"
|
||||
transform="translate(678.553909,292.480000) scale(0.138661)"
|
||||
style="font-family: Open Sans, verdana, arial, sans-serif !important; font-size: 12px; fill: rgb(255, 255, 255); fill-opacity: 1.00; white-space: pre;"
|
||||
data-math="N">cache/lru/lru.go</text>
|
||||
data-math="N">cache/lru.go</text>
|
||||
|
||||
</g>
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |