diff options
author | github-classroom[bot] <66690702+github-classroom[bot]@users.noreply.github.com> | 2022-02-28 19:36:23 +0000 |
---|---|---|
committer | github-classroom[bot] <66690702+github-classroom[bot]@users.noreply.github.com> | 2022-02-28 19:36:23 +0000 |
commit | 1dd0508d5d3c737f1ee9c723f580baf73b1cfd70 (patch) | |
tree | 6adcc5ef85f9cf0bbb205c577da0bac9148114dd /pkg/blockchain/blockinfodatabase/blockinfodatabase.go |
Initial commit
Diffstat (limited to 'pkg/blockchain/blockinfodatabase/blockinfodatabase.go')
-rw-r--r-- | pkg/blockchain/blockinfodatabase/blockinfodatabase.go | 32 |
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 +} |