Adding some utility functions

This commit is contained in:
Armon Dadgar 2014-01-07 16:58:16 -08:00
parent 7e96658fdb
commit 64d567c5be
2 changed files with 14 additions and 1 deletions

View File

@ -83,7 +83,7 @@ func (s *StateStore) Close() error {
// initialize is used to setup the store for use // initialize is used to setup the store for use
func (s *StateStore) initialize() error { func (s *StateStore) initialize() error {
// Setup the Env first // Setup the Env first
if err := s.env.SetMaxDBs(mdb.DBI(16)); err != nil { if err := s.env.SetMaxDBs(mdb.DBI(32)); err != nil {
return err return err
} }

View File

@ -1,6 +1,7 @@
package consul package consul
import ( import (
"encoding/binary"
"fmt" "fmt"
"github.com/hashicorp/serf/serf" "github.com/hashicorp/serf/serf"
"net" "net"
@ -112,3 +113,15 @@ func GetPrivateIP() (*net.IPNet, error) {
} }
return nil, fmt.Errorf("No private IP address found") return nil, fmt.Errorf("No private IP address found")
} }
// Converts bytes to an integer
func bytesToUint64(b []byte) uint64 {
return binary.BigEndian.Uint64(b)
}
// Converts a uint to a byte slice
func uint64ToBytes(u uint64) []byte {
buf := make([]byte, 8)
binary.BigEndian.PutUint64(buf, u)
return buf
}