aboutsummaryrefslogtreecommitdiff
path: root/pkg/blockchain/blockinfodatabase/blockinfodatabase.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/blockchain/blockinfodatabase/blockinfodatabase.go')
-rw-r--r--pkg/blockchain/blockinfodatabase/blockinfodatabase.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/pkg/blockchain/blockinfodatabase/blockinfodatabase.go b/pkg/blockchain/blockinfodatabase/blockinfodatabase.go
new file mode 100644
index 0000000..c49a625
--- /dev/null
+++ b/pkg/blockchain/blockinfodatabase/blockinfodatabase.go
@@ -0,0 +1,32 @@
+package blockinfodatabase
+
+import (
+ "Chain/pkg/utils"
+ "github.com/syndtr/goleveldb/leveldb"
+)
+
+// BlockInfoDatabase is a wrapper for a levelDB
+type BlockInfoDatabase struct {
+ db *leveldb.DB
+}
+
+// New returns a BlockInfoDatabase given a Config
+func New(config *Config) *BlockInfoDatabase {
+ db, err := leveldb.OpenFile(config.DatabasePath, nil)
+ if err != nil {
+ utils.Debug.Printf("Unable to initialize BlockInfoDatabase with path {%v}", config.DatabasePath)
+ }
+ return &BlockInfoDatabase{db: db}
+}
+
+// StoreBlockRecord stores a BlockRecord in the BlockInfoDatabase.
+func (blockInfoDB *BlockInfoDatabase) StoreBlockRecord(hash string, blockRecord *BlockRecord) {
+ //TODO
+}
+
+// GetBlockRecord returns a BlockRecord from the BlockInfoDatabase given
+// the relevant block's hash.
+func (blockInfoDB *BlockInfoDatabase) GetBlockRecord(hash string) *BlockRecord {
+ //TODO
+ return nil
+}