diff --git a/lockable_test.go b/lockable_test.go index 11e6340..787448f 100644 --- a/lockable_test.go +++ b/lockable_test.go @@ -10,7 +10,7 @@ const TestLockableType = NodeType("TEST_LOCKABLE") func lockableTestContext(t *testing.T, logs []string) *Context { ctx := logTestContext(t, logs) - err := ctx.RegisterNodeType(TestLockableType, []ExtType{ACLExtType, LockableExtType, ListenerExtType}) + err := ctx.RegisterNodeType(TestLockableType, []ExtType{ACLExtType, LockableExtType}) fatalErr(t, err) return ctx @@ -54,7 +54,15 @@ func TestLink(t *testing.T) { func TestLink10K(t *testing.T) { ctx := lockableTestContext(t, []string{"test"}) - NewLockable := func()(*Node, *ListenerExt) { + NewLockable := func()(*Node) { + l := NewNode(ctx, RandID(), TestLockableType, nil, + NewACLExt(lock_policy, link_policy), + NewLockableExt(), + ) + return l + } + + NewListener := func()(*Node, *ListenerExt) { listener := NewListenerExt(100000) l := NewNode(ctx, RandID(), TestLockableType, nil, listener, @@ -63,21 +71,22 @@ func TestLink10K(t *testing.T) { ) return l, listener } - l0, l0_listener := NewLockable() + + l0, l0_listener := NewListener() lockables := make([]*Node, 10000) for i, _ := range(lockables) { - lockables[i], _ = NewLockable() + lockables[i] = NewLockable() LinkRequirement(ctx, l0.ID, lockables[i].ID) } - ctx.Log.Logf("test", "CREATED_10K %d") + ctx.Log.Logf("test", "CREATED_10K") for i, _ := range(lockables) { (*GraphTester)(t).WaitForState(ctx, l0_listener, LinkSignalType, "linked_as_req", time.Millisecond*1000, fmt.Sprintf("No linked_as_req for %d", i)) } - ctx.Log.Logf("test", "LINKED_10K: %d") + ctx.Log.Logf("test", "LINKED_10K") } func TestLock(t *testing.T) { diff --git a/node.go b/node.go index 17360cb..5c2ea3c 100644 --- a/node.go +++ b/node.go @@ -12,6 +12,22 @@ import ( "sync/atomic" ) +const ( + // Size of node message channels + NODE_MSG_CHAN_DEFAULT = 1024 + // Magic first four bytes of serialized DB content, stored big endian + NODE_DB_MAGIC = 0x2491df14 + // Total length of the node database header, has magic to verify and type_hash to map to load function + NODE_DB_HEADER_LEN = 20 + EXTENSION_DB_HEADER_LEN = 16 +) + +var ( + // Base NodeID, used as a special value + ZeroUUID = uuid.UUID{} + ZeroID = NodeID(ZeroUUID) +) + // A NodeID uniquely identifies a Node type NodeID uuid.UUID func (id NodeID) MarshalJSON() ([]byte, error) { @@ -29,10 +45,6 @@ func (id *NodeID) UnmarshalJSON(bytes []byte) error { return err } -// Base NodeID, used as a special value -var ZeroUUID = uuid.UUID{} -var ZeroID = NodeID(ZeroUUID) - func (id NodeID) Serialize() []byte { ser, _ := (uuid.UUID)(id).MarshalBinary() return ser @@ -83,7 +95,6 @@ type QueuedSignal struct { } // Default message channel size for nodes -const NODE_MSG_CHAN_DEFAULT = 1024 // Nodes represent a group of extensions that can be collectively addressed type Node struct { ID NodeID @@ -365,10 +376,6 @@ func Allowed(ctx *Context, principal_id NodeID, action Action, node *Node) error return err } -// Magic first four bytes of serialized DB content, stored big endian -const NODE_DB_MAGIC = 0x2491df14 -// Total length of the node database header, has magic to verify and type_hash to map to load function -const NODE_DB_HEADER_LEN = 20 // A DBHeader is parsed from the first NODE_DB_HEADER_LEN bytes of a serialized DB node type NodeDBHeader struct { Magic uint32 @@ -473,7 +480,6 @@ func (extension ExtensionDB) Serialize() []byte { return append(header_bytes, extension.Data...) } -const EXTENSION_DB_HEADER_LEN = 16 type ExtensionDBHeader struct { TypeHash uint64 Length uint64