Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pull buffered blockstore into the lib folder #7

Merged
merged 1 commit into from
Jul 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions chain/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"math/big"

"github.com/filecoin-project/go-lotus/chain/address"
"github.com/filecoin-project/go-lotus/lib/bufbstore"

bserv "github.com/ipfs/go-blockservice"
cid "github.com/ipfs/go-cid"
Expand Down Expand Up @@ -64,13 +65,13 @@ type VM struct {
cstate *StateTree
base cid.Cid
cs *ChainStore
buf *BufferedBS
buf *bufbstore.BufferedBS
blockHeight uint64
blockMiner address.Address
}

func NewVM(base cid.Cid, height uint64, maddr address.Address, cs *ChainStore) (*VM, error) {
buf := NewBufferedBstore(cs.bs)
buf := bufbstore.NewBufferedBstore(cs.bs)
cst := hamt.CSTFromBstore(buf)
state, err := LoadStateTree(cst, base)
if err != nil {
Expand Down Expand Up @@ -166,7 +167,7 @@ func (vm *VM) ApplyMessage(msg *Message) (*MessageReceipt, error) {

func (vm *VM) Flush(ctx context.Context) (cid.Cid, error) {
from := dag.NewDAGService(bserv.New(vm.buf, nil))
to := dag.NewDAGService(bserv.New(vm.buf.read, nil))
to := dag.NewDAGService(bserv.New(vm.buf.Read(), nil))

root, err := vm.cstate.Flush()
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion chain/buf_bstore.go → lib/bufbstore/buf_bstore.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chain
package bufbstore

import (
"context"
Expand Down Expand Up @@ -115,3 +115,7 @@ func (bs *BufferedBS) HashOnRead(hor bool) {
func (bs *BufferedBS) PutMany(blks []block.Block) error {
return bs.write.PutMany(blks)
}

func (bs *BufferedBS) Read() bstore.Blockstore {
return bs.read
}