NodeStateMachine implements a network node-related event subscription system. It can assign binary state flags and fields of arbitrary type to each node and allows subscriptions to flag/field changes which can also modify further flags and fields, potentially triggering further subscriptions. An ope
| 62 | // potentially performs state/field changes then it is recommended to mention this fact in the |
| 63 | // function description, along with whether it should run inside an operation callback. |
| 64 | NodeStateMachine struct { |
| 65 | started, closed bool |
| 66 | lock sync.Mutex |
| 67 | clock mclock.Clock |
| 68 | db ethdb.KeyValueStore |
| 69 | dbNodeKey []byte |
| 70 | nodes map[enode.ID]*nodeInfo |
| 71 | offlineCallbackList []offlineCallback |
| 72 | opFlag bool // an operation has started |
| 73 | opWait *sync.Cond // signaled when the operation ends |
| 74 | opPending []func() // pending callback list of the current operation |
| 75 | |
| 76 | // Registered state flags or fields. Modifications are allowed |
| 77 | // only when the node state machine has not been started. |
| 78 | setup *Setup |
| 79 | fields []*fieldInfo |
| 80 | saveFlags bitMask |
| 81 | |
| 82 | // Installed callbacks. Modifications are allowed only when the |
| 83 | // node state machine has not been started. |
| 84 | stateSubs []stateSub |
| 85 | |
| 86 | // Testing hooks, only for testing purposes. |
| 87 | saveNodeHook func(*nodeInfo) |
| 88 | } |
| 89 | |
| 90 | // Flags represents a set of flags from a certain setup |
| 91 | Flags struct { |
nothing calls this directly
no outgoing calls
no test coverage detected