cleanup
This commit is contained in:
parent
994f0180bc
commit
f5520656e5
2 changed files with 17 additions and 9 deletions
18
db/db.go
18
db/db.go
|
@ -4,7 +4,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
@ -23,6 +22,7 @@ import (
|
||||||
//
|
//
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// Blochchain height / expiration constants
|
||||||
NOriginalClaimExpirationTime = 262974
|
NOriginalClaimExpirationTime = 262974
|
||||||
NExtendedClaimExpirationTime = 2102400
|
NExtendedClaimExpirationTime = 2102400
|
||||||
NExtendedClaimExpirationForkHeight = 400155
|
NExtendedClaimExpirationForkHeight = 400155
|
||||||
|
@ -33,6 +33,8 @@ const (
|
||||||
NAllClaimsInMerkleForkHeight = 658310 // targeting 30 Oct 2019
|
NAllClaimsInMerkleForkHeight = 658310 // targeting 30 Oct 2019
|
||||||
ProportionalDelayFactor = 32
|
ProportionalDelayFactor = 32
|
||||||
MaxTakeoverDelay = 4032
|
MaxTakeoverDelay = 4032
|
||||||
|
// Initial size constants
|
||||||
|
InitialTxCountSize = 1200000
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -265,14 +267,21 @@ func BisectRight(arr []interface{}, val uint32) uint32 {
|
||||||
// Iterators / db construction functions
|
// Iterators / db construction functions
|
||||||
//
|
//
|
||||||
|
|
||||||
|
func intMin(a, b int) int {
|
||||||
|
if a < b {
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
func (o *IterOptions) StopIteration(key []byte) bool {
|
func (o *IterOptions) StopIteration(key []byte) bool {
|
||||||
if key == nil {
|
if key == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Look at not doing floating point conversions for this
|
// TODO: Look at not doing floating point conversions for this
|
||||||
maxLenStop := int(math.Min(float64(len(key)), float64(len(o.Stop))))
|
maxLenStop := intMin(len(key), len(o.Stop))
|
||||||
maxLenStart := int(math.Min(float64(len(key)), float64(len(o.Start))))
|
maxLenStart := intMin(len(key), len(o.Start))
|
||||||
if o.Stop != nil &&
|
if o.Stop != nil &&
|
||||||
(bytes.HasPrefix(key, o.Stop) || bytes.Compare(o.Stop, key[:maxLenStop]) < 0) {
|
(bytes.HasPrefix(key, o.Stop) || bytes.Compare(o.Stop, key[:maxLenStop]) < 0) {
|
||||||
return true
|
return true
|
||||||
|
@ -771,8 +780,7 @@ func InitTxCounts(db *ReadOnlyDBColumnFamily) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: figure out a reasonable default and make it a constant
|
db.TxCounts = db_stack.NewSliceBackedStack(InitialTxCountSize)
|
||||||
db.TxCounts = db_stack.NewSliceBackedStack(1200000)
|
|
||||||
|
|
||||||
options := NewIterateOptions().WithPrefix([]byte{prefixes.TxCount}).WithCfHandle(handle)
|
options := NewIterateOptions().WithPrefix([]byte{prefixes.TxCount}).WithCfHandle(handle)
|
||||||
options = options.WithIncludeKey(false).WithIncludeValue(true).WithIncludeStop(true)
|
options = options.WithIncludeKey(false).WithIncludeValue(true).WithIncludeStop(true)
|
||||||
|
|
|
@ -488,9 +488,9 @@ func (s *Server) Resolve(ctx context.Context, args *pb.StringValue) (*pb.Outputs
|
||||||
return &pb.Outputs{
|
return &pb.Outputs{
|
||||||
Txos: txos,
|
Txos: txos,
|
||||||
ExtraTxos: extraTxos,
|
ExtraTxos: extraTxos,
|
||||||
Total: 1,
|
Total: uint32(len(txos) + len(extraTxos)),
|
||||||
Offset: 0,
|
Offset: 0, //TODO
|
||||||
Blocked: nil,
|
Blocked: nil, //TODO
|
||||||
BlockedTotal: 0,
|
BlockedTotal: 0, //TODO
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue