diff --git a/context.go b/context.go index 46d0f5a..ce6e2c8 100644 --- a/context.go +++ b/context.go @@ -2,6 +2,7 @@ package graphvent import ( "crypto/ecdh" + "sort" "time" "encoding/binary" "errors" @@ -975,6 +976,11 @@ func NewContext(db * badger.DB, log Logger) (*Context, error) { map_size := 0 map_iter := value.MapRange() + type TreeMapValue struct{ + Key SerializedType + Data []byte + } + value_stacks := []TreeMapValue{} for map_iter.Next() { map_size += 1 key_reflect := map_iter.Key() @@ -989,8 +995,19 @@ func NewContext(db * badger.DB, log Logger) (*Context, error) { return SerializedValue{}, err } - data = append(data, key_value.Data...) - data = append(data, elem_value.Data...) + value_stacks = append(value_stacks, TreeMapValue{ + SerializedType(key_reflect.Uint()), + append(key_value.Data, elem_value.Data...), + }) + } + + // Sort the value_stacks, then add them to `data` + sort.Slice(value_stacks, func(i, j int) bool { + return value_stacks[i].Key > value_stacks[j].Key + }) + + for _, stack := range(value_stacks) { + data = append(data, stack.Data...) } binary.BigEndian.PutUint64(data[0:8], uint64(map_size)) diff --git a/gql.go b/gql.go index 300bc82..001f31e 100644 --- a/gql.go +++ b/gql.go @@ -242,7 +242,7 @@ func GraphiQLHandler() func(http.ResponseWriter, *http.Request) { fetcher: GraphiQL.createFetcher({ url: '/gql', headers: { - "Authorization": ` + "`Basic ${res}`" + `, + "Authorization": ` + "`${res}`" + `, }, }), defaultEditorToolsVisibility: true, diff --git a/node.go b/node.go index b0185f0..07bc8b5 100644 --- a/node.go +++ b/node.go @@ -294,7 +294,7 @@ func nodeLoop(ctx *Context, node *Node) error { } validated := ed25519.Verify(msg.Source, sig_data, msg.Signature) if validated == false { - ctx.Log.Logf("signal", "SIGNAL_VERIFY_ERR: %s - %+v", node.ID, msg) + ctx.Log.Logf("signal", "SIGNAL_VERIFY_ERR: %s - %s", node.ID, reflect.TypeOf(msg.Signal)) continue } @@ -426,7 +426,7 @@ func nodeLoop(ctx *Context, node *Node) error { } err = node.DequeueSignal(req_info.TimeoutID) if err != nil { - panic("dequeued a passed signal") + ctx.Log.Logf("node", "ACL_DEQUEUE_ERROR: timeout signal not in queue when trying to clear after counter hit 0 %s, %s - %s", err, signal.ID(), req_info.TimeoutID) } delete(node.PendingACLs, info.ID) } else { diff --git a/serialize_test.go b/serialize_test.go index 1e91138..8f43fcc 100644 --- a/serialize_test.go +++ b/serialize_test.go @@ -66,6 +66,12 @@ func TestSerializeBasic(t *testing.T) { "test_string", }) + testSerialize(t, ctx, Tree{ + ErrorType: nil, + MapType: nil, + StringType: nil, + }) + testSerialize(t, ctx, Tree{ TreeType: nil, })