forked from lightningnetwork/lnd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
channeldb: MigrateOutpointIndex, store indexStatus in outpoint index
Adds an outpoint index that stores a tlv stream. Currently the stream only contains the outpoint's indexStatus. This should cut down on big bbolt transactions in several places throughout the codebase.
- Loading branch information
1 parent
08ee754
commit 204b6c5
Showing
5 changed files
with
354 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package migration20 | ||
|
||
import ( | ||
"encoding/binary" | ||
"io" | ||
|
||
"github.com/btcsuite/btcd/wire" | ||
) | ||
|
||
var ( | ||
byteOrder = binary.BigEndian | ||
) | ||
|
||
// writeOutpoint writes an outpoint from the passed writer. | ||
func writeOutpoint(w io.Writer, o *wire.OutPoint) error { | ||
if _, err := w.Write(o.Hash[:]); err != nil { | ||
return err | ||
} | ||
if err := binary.Write(w, byteOrder, o.Index); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// readOutpoint reads an outpoint from the passed reader. | ||
func readOutpoint(r io.Reader, o *wire.OutPoint) error { | ||
if _, err := io.ReadFull(r, o.Hash[:]); err != nil { | ||
return err | ||
} | ||
if err := binary.Read(r, byteOrder, &o.Index); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package migration20 | ||
|
||
import ( | ||
"github.com/btcsuite/btclog" | ||
) | ||
|
||
// log is a logger that is initialized as disabled. This means the package | ||
// will not perform any logging by default until a logger is set. | ||
var log = btclog.Disabled | ||
|
||
// UseLogger uses a specified Logger to output package logging info. | ||
func UseLogger(logger btclog.Logger) { | ||
log = logger | ||
} |
Oops, something went wrong.