multi: switch from bolt packge to bbolt package for all imports
This commit is contained in:
41 files changed
+404
-405
No files matched your search
+17
-17
@@ -281,7 +281,7 @@ var (
|
||||
// boltArbitratorLog is an implementation of the ArbitratorLog interface backed
|
||||
// by a bolt DB instance.
|
||||
type boltArbitratorLog struct {
|
||||
db *bolt.DB
|
||||
db *bbolt.DB
|
||||
|
||||
cfg ChannelArbitratorConfig
|
||||
|
||||
@@ -290,7 +290,7 @@ type boltArbitratorLog struct {
|
||||
|
||||
// newBoltArbitratorLog returns a new instance of the boltArbitratorLog given
|
||||
// an arbitrator config, and the items needed to create its log scope.
|
||||
func newBoltArbitratorLog(db *bolt.DB, cfg ChannelArbitratorConfig,
|
||||
func newBoltArbitratorLog(db *bbolt.DB, cfg ChannelArbitratorConfig,
|
||||
chainHash chainhash.Hash, chanPoint wire.OutPoint) (*boltArbitratorLog, error) {
|
||||
|
||||
scope, err := newLogScope(chainHash, chanPoint)
|
||||
@@ -309,7 +309,7 @@ func newBoltArbitratorLog(db *bolt.DB, cfg ChannelArbitratorConfig,
|
||||
// interface.
|
||||
var _ ArbitratorLog = (*boltArbitratorLog)(nil)
|
||||
|
||||
func fetchContractReadBucket(tx *bolt.Tx, scopeKey []byte) (*bolt.Bucket, error) {
|
||||
func fetchContractReadBucket(tx *bbolt.Tx, scopeKey []byte) (*bbolt.Bucket, error) {
|
||||
scopeBucket := tx.Bucket(scopeKey)
|
||||
if scopeBucket == nil {
|
||||
return nil, errScopeBucketNoExist
|
||||
@@ -323,7 +323,7 @@ func fetchContractReadBucket(tx *bolt.Tx, scopeKey []byte) (*bolt.Bucket, error)
|
||||
return contractBucket, nil
|
||||
}
|
||||
|
||||
func fetchContractWriteBucket(tx *bolt.Tx, scopeKey []byte) (*bolt.Bucket, error) {
|
||||
func fetchContractWriteBucket(tx *bbolt.Tx, scopeKey []byte) (*bbolt.Bucket, error) {
|
||||
scopeBucket, err := tx.CreateBucketIfNotExists(scopeKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -341,7 +341,7 @@ func fetchContractWriteBucket(tx *bolt.Tx, scopeKey []byte) (*bolt.Bucket, error
|
||||
|
||||
// writeResolver is a helper method that writes a contract resolver and stores
|
||||
// it it within the passed contractBucket using its unique resolutionsKey key.
|
||||
func (b *boltArbitratorLog) writeResolver(contractBucket *bolt.Bucket,
|
||||
func (b *boltArbitratorLog) writeResolver(contractBucket *bbolt.Bucket,
|
||||
res ContractResolver) error {
|
||||
|
||||
// First, we'll write to the buffer the type of this resolver. Using
|
||||
@@ -382,7 +382,7 @@ func (b *boltArbitratorLog) writeResolver(contractBucket *bolt.Bucket,
|
||||
// NOTE: Part of the ContractResolver interface.
|
||||
func (b *boltArbitratorLog) CurrentState() (ArbitratorState, error) {
|
||||
var s ArbitratorState
|
||||
err := b.db.View(func(tx *bolt.Tx) error {
|
||||
err := b.db.View(func(tx *bbolt.Tx) error {
|
||||
scopeBucket := tx.Bucket(b.scopeKey[:])
|
||||
if scopeBucket == nil {
|
||||
return errScopeBucketNoExist
|
||||
@@ -407,7 +407,7 @@ func (b *boltArbitratorLog) CurrentState() (ArbitratorState, error) {
|
||||
//
|
||||
// NOTE: Part of the ContractResolver interface.
|
||||
func (b *boltArbitratorLog) CommitState(s ArbitratorState) error {
|
||||
return b.db.Batch(func(tx *bolt.Tx) error {
|
||||
return b.db.Batch(func(tx *bbolt.Tx) error {
|
||||
scopeBucket, err := tx.CreateBucketIfNotExists(b.scopeKey[:])
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -427,7 +427,7 @@ func (b *boltArbitratorLog) FetchUnresolvedContracts() ([]ContractResolver, erro
|
||||
Checkpoint: b.checkpointContract,
|
||||
}
|
||||
var contracts []ContractResolver
|
||||
err := b.db.View(func(tx *bolt.Tx) error {
|
||||
err := b.db.View(func(tx *bbolt.Tx) error {
|
||||
contractBucket, err := fetchContractReadBucket(tx, b.scopeKey[:])
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -518,7 +518,7 @@ func (b *boltArbitratorLog) FetchUnresolvedContracts() ([]ContractResolver, erro
|
||||
//
|
||||
// NOTE: Part of the ContractResolver interface.
|
||||
func (b *boltArbitratorLog) InsertUnresolvedContracts(resolvers ...ContractResolver) error {
|
||||
return b.db.Batch(func(tx *bolt.Tx) error {
|
||||
return b.db.Batch(func(tx *bbolt.Tx) error {
|
||||
contractBucket, err := fetchContractWriteBucket(tx, b.scopeKey[:])
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -541,7 +541,7 @@ func (b *boltArbitratorLog) InsertUnresolvedContracts(resolvers ...ContractResol
|
||||
//
|
||||
// NOTE: Part of the ContractResolver interface.
|
||||
func (b *boltArbitratorLog) SwapContract(oldContract, newContract ContractResolver) error {
|
||||
return b.db.Batch(func(tx *bolt.Tx) error {
|
||||
return b.db.Batch(func(tx *bbolt.Tx) error {
|
||||
contractBucket, err := fetchContractWriteBucket(tx, b.scopeKey[:])
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -561,7 +561,7 @@ func (b *boltArbitratorLog) SwapContract(oldContract, newContract ContractResolv
|
||||
//
|
||||
// NOTE: Part of the ContractResolver interface.
|
||||
func (b *boltArbitratorLog) ResolveContract(res ContractResolver) error {
|
||||
return b.db.Batch(func(tx *bolt.Tx) error {
|
||||
return b.db.Batch(func(tx *bbolt.Tx) error {
|
||||
contractBucket, err := fetchContractWriteBucket(tx, b.scopeKey[:])
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -579,7 +579,7 @@ func (b *boltArbitratorLog) ResolveContract(res ContractResolver) error {
|
||||
//
|
||||
// NOTE: Part of the ContractResolver interface.
|
||||
func (b *boltArbitratorLog) LogContractResolutions(c *ContractResolutions) error {
|
||||
return b.db.Batch(func(tx *bolt.Tx) error {
|
||||
return b.db.Batch(func(tx *bbolt.Tx) error {
|
||||
scopeBucket, err := tx.CreateBucketIfNotExists(b.scopeKey[:])
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -640,7 +640,7 @@ func (b *boltArbitratorLog) LogContractResolutions(c *ContractResolutions) error
|
||||
// NOTE: Part of the ContractResolver interface.
|
||||
func (b *boltArbitratorLog) FetchContractResolutions() (*ContractResolutions, error) {
|
||||
c := &ContractResolutions{}
|
||||
err := b.db.View(func(tx *bolt.Tx) error {
|
||||
err := b.db.View(func(tx *bbolt.Tx) error {
|
||||
scopeBucket := tx.Bucket(b.scopeKey[:])
|
||||
if scopeBucket == nil {
|
||||
return errScopeBucketNoExist
|
||||
@@ -726,7 +726,7 @@ func (b *boltArbitratorLog) FetchContractResolutions() (*ContractResolutions, er
|
||||
//
|
||||
// NOTE: Part of the ContractResolver interface.
|
||||
func (b *boltArbitratorLog) LogChainActions(actions ChainActionMap) error {
|
||||
return b.db.Batch(func(tx *bolt.Tx) error {
|
||||
return b.db.Batch(func(tx *bbolt.Tx) error {
|
||||
scopeBucket, err := tx.CreateBucketIfNotExists(b.scopeKey[:])
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -765,7 +765,7 @@ func (b *boltArbitratorLog) LogChainActions(actions ChainActionMap) error {
|
||||
func (b *boltArbitratorLog) FetchChainActions() (ChainActionMap, error) {
|
||||
actionsMap := make(ChainActionMap)
|
||||
|
||||
err := b.db.View(func(tx *bolt.Tx) error {
|
||||
err := b.db.View(func(tx *bbolt.Tx) error {
|
||||
scopeBucket := tx.Bucket(b.scopeKey[:])
|
||||
if scopeBucket == nil {
|
||||
return errScopeBucketNoExist
|
||||
@@ -807,7 +807,7 @@ func (b *boltArbitratorLog) FetchChainActions() (ChainActionMap, error) {
|
||||
//
|
||||
// NOTE: Part of the ContractResolver interface.
|
||||
func (b *boltArbitratorLog) WipeHistory() error {
|
||||
return b.db.Update(func(tx *bolt.Tx) error {
|
||||
return b.db.Update(func(tx *bbolt.Tx) error {
|
||||
scopeBucket, err := tx.CreateBucketIfNotExists(b.scopeKey[:])
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -870,7 +870,7 @@ func (b *boltArbitratorLog) WipeHistory() error {
|
||||
// ContractResolver instances to checkpoint their state once they reach
|
||||
// milestones during contract resolution.
|
||||
func (b *boltArbitratorLog) checkpointContract(c ContractResolver) error {
|
||||
return b.db.Batch(func(tx *bolt.Tx) error {
|
||||
return b.db.Batch(func(tx *bbolt.Tx) error {
|
||||
contractBucket, err := fetchContractWriteBucket(tx, b.scopeKey[:])
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in new issue
Block a user