doc.go 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2019 The go-ethereum Authors
  2. // This file is part of the go-ethereum library.
  3. //
  4. // The go-ethereum library is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Lesser General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // The go-ethereum library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Lesser General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Lesser General Public License
  15. // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
  16. /*
  17. Package localstore provides disk storage layer for Swarm Chunk persistence.
  18. It uses swarm/shed abstractions on top of github.com/syndtr/goleveldb LevelDB
  19. implementation.
  20. The main type is DB which manages the storage by providing methods to
  21. access and add Chunks and to manage their status.
  22. Modes are abstractions that do specific changes to Chunks. There are three
  23. mode types:
  24. - ModeGet, for Chunk access
  25. - ModePut, for adding Chunks to the database
  26. - ModeSet, for changing Chunk statuses
  27. Every mode type has a corresponding type (Getter, Putter and Setter)
  28. that provides adequate method to perform the opperation and that type
  29. should be injected into localstore consumers instead the whole DB.
  30. This provides more clear insight which operations consumer is performing
  31. on the database.
  32. Getters, Putters and Setters accept different get, put and set modes
  33. to perform different actions. For example, ModeGet has two different
  34. variables ModeGetRequest and ModeGetSync and two different Getters
  35. can be constructed with them that are used when the chunk is requested
  36. or when the chunk is synced as this two events are differently changing
  37. the database.
  38. Subscription methods are implemented for a specific purpose of
  39. continuous iterations over Chunks that should be provided to
  40. Push and Pull syncing.
  41. DB implements an internal garbage collector that removes only synced
  42. Chunks from the database based on their most recent access time.
  43. Internally, DB stores Chunk data and any required information, such as
  44. store and access timestamps in different shed indexes that can be
  45. iterated on by garbage collector or subscriptions.
  46. */
  47. package localstore