From 64d567c5be43d805d89a651fc29f831994ff7d4b Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Tue, 7 Jan 2014 16:58:16 -0800 Subject: [PATCH] Adding some utility functions --- consul/state_store.go | 2 +- consul/util.go | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/consul/state_store.go b/consul/state_store.go index 84cc600af4..8284b5c5c5 100644 --- a/consul/state_store.go +++ b/consul/state_store.go @@ -83,7 +83,7 @@ func (s *StateStore) Close() error { // initialize is used to setup the store for use func (s *StateStore) initialize() error { // 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 } diff --git a/consul/util.go b/consul/util.go index b1ca085c63..826010547b 100644 --- a/consul/util.go +++ b/consul/util.go @@ -1,6 +1,7 @@ package consul import ( + "encoding/binary" "fmt" "github.com/hashicorp/serf/serf" "net" @@ -112,3 +113,15 @@ func GetPrivateIP() (*net.IPNet, error) { } 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 +}