* [NOD-1162] [FIX] Connection manager should run the moment it adds a request
* [NOD-1162] [FIX] Set peerID on handshake
* [NOD-1162] [FIX] Broadcast should send to outgoing route, not incoming
* [NOD-1162] [FIX] Add CmdInvRelayBlock to MakeEmptyMessage
* [NOD-1162] [FIX] Initialize Hash before decoding MsgInvRelayBlock
* [NOD-1162] [FIX] Invert condition
* [NOD-1162] [FIX] Fixes to encoding of MsgGetRelayBlocks
* [NOD-1162] [FIX] Add MsgGetRelayBlocks to MakeEmptyMessage
* [NOD-1162] Add comment
* [NOD-1123] Bubble bad-message errors up to the protocol level.
* [NOD-1123] Implement Banning.
* [NOD-1123] Properly use &stopped.
* [NOD-1123] Ban by IP rather than IP and port.
* [NOD-1123] Don't initiate connections to banned peers.
* [NOD-1123] Fix infinite loop in checkOutgoingConnections.
* [NOD-1123] Fix bannedAddresses key.
* [NOD-1123] Rename onBadMessageHandler to onInvalidMessageHandler.
* [NOD-1175] Get rid of something weird.
* [NOD-1175] Implement AddBlock.
* [NOD-1175] Implement BFDisallowOrphans.
* [NOD-1175] Pass flags into AddBlock.
* [NOD-1175] Remove isOrphan and isDelayed handling from AddBlock.
* [NOD-1175] Use default return values in error.
* [NOD-1175] Bring back a comment.
* [NOD-1175] Add ErrOrphanBlockIsNotAllowed to errorCodeStrings.
* [NOD-1170] Return a custom error when a route is closed
* [NOD-1170] Return ErrRouteClosed directly from route methods
* [NOD-1170] Fix comment location
* [NOD-1164] Defined DatabaseContext as the basic object of dbaccess
* [NOD-1164] Update everything to use databaseContext
* [NOD-1164] Fix tests
* [NOD-1164] Add comments
* [NOD-1164] Removed databaseContext from blockNode
* [NOD-1164] Enforce DatabaseContext != nil
* [NOD-1164] Remove redundant and wrong comment line
* [NOD-1125] Write a skeleton for starting IBD.
* [NOD-1125] Add WaitForIBDStart to Peer.
* [NOD-1125] Move functions around.
* [NOD-1125] Fix merge errors.
* [NOD-1125] Fix a comment.
* [NOD-1125] Implement sendGetBlockLocator.
* [NOD-1125] Begin implementing findIBDLowHash.
* [NOD-1125] Finish implementing findIBDLowHash.
* [NOD-1125] Rename findIBDLowHash to findHighestSharedBlockHash.
* [NOD-1125] Implement downloadBlocks.
* [NOD-1125] Implement msgIBDBlock.
* [NOD-1125] Implement msgIBDBlock.
* [NOD-1125] Fix message types for HandleIBD.
* [NOD-1125] Write a skeleton for requesting selected tip hashes.
* [NOD-1125] Write a skeleton for the rest of the IBD requests.
* [NOD-1125] Implement HandleGetBlockLocator.
* [NOD-1125] Fix wrong timeout.
* [NOD-1125] Fix compilation error.
* [NOD-1125] Implement HandleGetBlocks.
* [NOD-1125] Fix compilation errors.
* [NOD-1125] Fix merge errors.
* [NOD-1125] Implement selectPeerForIBD.
* [NOD-1125] Implement RequestSelectedTip.
* [NOD-1125] Implement HandleGetSelectedTip.
* [NOD-1125] Make go lint happy.
* [NOD-1125] Add minGetSelectedTipInterval.
* [NOD-1125] Call StartIBDIfRequired where needed.
* [NOD-1125] Fix merge errors.
* [NOD-1125] Remove a redundant line.
* [NOD-1125] Rename shouldContinue to shouldStop.
* [NOD-1125] Lowercasify an error message.
* [NOD-1125] Shuffle statements around in findHighestSharedBlockHash.
* [NOD-1125] Rename hasRecentlyReceivedBlock to isDAGTimeCurrent.
* [NOD-1125] Scope minGetSelectedTipInterval.
* [NOD-1125] Handle an unhandled error.
* [NOD-1125] Use AddUint32 instead of LoadUint32 + StoreUint32.
* [NOD-1125] Use AddUint32 instead of LoadUint32 + StoreUint32.
* [NOD-1125] Use SwapUint32 instead of AddUint32.
* [NOD-1125] Remove error from requestSelectedTips.
* [NOD-1125] Actually stop IBD when it should stop.
* [NOD-1125] Actually stop RequestSelectedTip when it should stop.
* [NOD-1125] Don't ban peers that send us delayed blocks during IBD.
* [NOD-1125] Make unexpected message type messages nicer.
* [NOD-1125] Remove Peer.ready and make HandleHandshake return it to guarantee we never operate on a non-initialized peer.
* [NOD-1125] Remove errors associated with Peer.ready.
* [NOD-1125] Extract maxHashesInMsgIBDBlocks to a const.
* [NOD-1125] Move the ibd package into flows.
* [NOD-1125] Start IBD if required after getting an unknown block inv.
* [NOD-1125] Don't request blocks during relay if we're in the middle of IBD.
* [NOD-1125] Remove AddBlockLocatorHash.
* [NOD-1125] Extract runIBD to a seperate function.
* [NOD-1125] Extract runSelectedTipRequest to a seperate function.
* [NOD-1125] Remove EnqueueWithTimeout.
* [NOD-1125] Increase the capacity of the outgoingRoute.
* [NOD-1125] Fix some bad names.
* [NOD-1125] Fix a comment.
* [NOD-1125] Simplify a comment.
* [NOD-1125] Move WaitFor... functions into their respective run... functions.
* [NOD-1125] Return default values in case of error.
* [NOD-1125] Use CmdXXX in error messages.
* [NOD-1125] Use MaxInvPerMsg in outgoingRouteMaxMessages instead of MaxBlockLocatorsPerMsg.
* [NOD-1125] Fix a comment.
* [NOD-1125] Disconnect a peer that sends us a delayed block during IBD.
* [NOD-1125] Use StoreUint32 instead of SwapUint32.
* [NOD-1125] Add a comment.
* [NOD-1125] Don't ban peers that send us delayed blocks.
* [NOD-1148] Add lock around route's close operation
* [NOD-1148] Added tracing of incoming and outgoing messages
* [NOD-1148] Cast to MsgPing should have been to MsgPong
* [NOD-1148] Check for NeedMoreAddresses before sending GetAddr message
and invert condition
* [NOD-1163] Combine seperated flows into single packages
* [NOD-1163] Move handshake.go to handshake package
* [NOD-1163] Use single logger prefix for everything under protocol
* [NOD-1163] Add comment
* [NOD-1163] Fix refactor error
* [NOD-1120] Removed closure in NetAdapter.onConnectedHanlder
* [NOD-1120] Implement all connection manager methods
* [NOD-1120] Integrated connmanager into kaspad + added call for dnsseeder
* [NOD-1120] Allow buffer to not be bytes.Buffer
* [NOD-1120] Added timeout to connect
* [NOD-1120] Don't enter connections to add loop if none needed
* [NOD-1120] Add call for addressManager.Good
* [NOD-1120] Minor bug fixes
* [NOD-1120] Remove errChan from grpcConnection
* [NOD-1120] Add comments to exported methods
* [NOD-1120] cancel the context for DialContext in gRPCServer.Connect
* [NOD-1120] Don't try to remove from connSet a connection that doesn't exist
* [NOD-1120] add ok bool to connectionSet.get
* [NOD-1120] Remove overuse of if-else in checkConnectionRequests
* [NOD-1120] Made some order in ConnectionManager
* [NOD-1120] Moved checkIncomingConnections to it's own file
* [NOD-1120] cleanup in checkOutgoingConnections
* [NOD-1120] Cleanup in SeedDNS, and move call outside of connection manager
* [NOD-1120] Add check that both --connect and --addpeer aren't used
* [NOD-1120] Move dial timeout to constant
* [NOD-1120] Enhance comment
* [NOD-1120] Log connection failure out of initiateConnection
* [NOD-1148] Reshuffle checkRequestedConnections to make more sense
* [NOD-1120] Move continue to correct place + reshuffle logging code
* [NOD-1120] Don't expose server.Connection outside netAdapter - expose a wrapper instead
* [NOD-1120] Add comments
* [NOD-1120] Don't return the connection from netAdapter.Connect()
* [NOD-1120] Use .Address as key for connectionSet
* [NOD-1120] Fix minRetryDuration usage
* [NOD-1120] Remove the correct number of incoming connections
* [NOD-1120] Add comment
* [NOD-1120] Rename connSet -> incomingConnectionSet
* [NOD-1120] fix grammar
* [NOD-1142] Implement EnqueueWithTimeout and DequeueWithTimeout.
* [NOD-1142] Use DequeueWithTimeout in readMsgBlock.
* [NOD-1142] Add comments about the new methods.
* [NOD-1124] Move Router to the router package.
* [NOD-1124] Implement SetOnRouteCapacityReachedHandler.
* [NOD-1124] Use Routes instead of bare channels.
* [NOD-1124] Fix merge errors.
* [NOD-1124] Connect the Router to the Connection.
* [NOD-1124] Fix merge errors.
* [NOD-1124] Move some variables around.
* [NOD-1124] Fix unreachable code.
* [NOD-1124] Fix a variable name.
* [NOD-1124] Rename AddRoute to AddIncomingRoute.
* [NOD-1124] Rename SetRouter to Start.
* [NOD-1124] Make AddIncomingRoute create a Route by itself.
* [NOD-1124] Replace IncomingRoute with EnqueueIncomingMessage.
* [NOD-1124] Make Enqueue and Dequeue return isOpen instead of err.
* [NOD-1124] Remove writeDuringDisconnectLock.
* [NOD-1124] In sendLoop, move outgoingRoute to outside the loop.
* [NOD-1124] Start the connection loops only when Start is called.
* [NOD-1124] Replace OnIDReceivedHandler with AssociateRouterID.
* [NOD-1124] Add isOpen to Enqueue and Dequeue.
* [NOD-1124] Protect errChan from writing during disconnect.
* [NOD-1118] Added protobufs for the MessageStream
* [NOD-1118] Implement some of the basic grpc methods
* [NOD-1118] Implemented gRPCConnection send and receive
* [NOD-1118] Implemented basic connection loops
* [NOD-1118] gRPC server implementation ready
* [NOD-1118] Add connection management
* [NOD-1118] Sort out the connection loops
* [NOD-1118] Add temporary testConnection
* [NOD-1118] Send to c.errChan whether error was recieved or not
* [NOD-1118] Call OnConnectHandler in time
* [NOD-1118] Handle closing connections properly
* [NOD-1118] Add comments to exported functions
* [NOD-1118] Call server.addConnection on newConnection
* [NOD-1118] Add a TODO comment
* [NOD-1118] Add a TODO comment
* [NOD-1118] Make connection a Stringer
* [NOD-1118] Made the connection loops 100% synchronic
* [NOD-1118] Make connection.isConnected uint32
* [NOD-1118] Move the Add/Remove connection from grpcConnection to register/unregister connection
* [NOD-1118] Convert error messages to lower case
* [NOD-1118] Remove protoc inline dependency
* [NOD-1118] Fix comment
* [NOD-1118] Exit if there was an error starting the protocol manager
* [NOD-1118] Fix error message
* [NOD-1118] Fixed a few comments
* [NOD-1118] Extract listenOn to a method
* [NOD-1118] Use !=0 for isConnected
* [NOD-1118] Refactor listenOn
* [NOD-1118] Add lock on channelWrites in gRPCConnection
* [NOD-1118] Rename channelWriteLock -> writeDuringDisconnectLock
* [NOD-1118] Reshuffle a comment
* [NOD-1118] Add a TODO comment
* [NOD-1124] Rename Peer to Connection (because Peer is a business logic term)
* [NOD-1124] Implement Close for Router.
* [NOD-1124] Add SetPeerDisconnectedHandler.
* [NOD-1124] Remove mentions of "peer" from the netadapter package.
* [NOD-1124] Handle errors/stopping in netadapter.
* [NOD-1124] Remove netadapter.Connection.
* [NOD-1124] Add startSendLoop.
* [NOD-1124] Implement network IDs.
* [NOD-1124] Implement a map between IDs and routes.
* [NOD-1124] Implement Broadcast.
* [NOD-1124] Fix rename error.
* [NOD-1124] Fix copy+paste error.
* [NOD-1124] Change the type of NetAdapter.stop to uint32.
* [NOD-1124] If NetAdapter is stopped more than once, return an error.
* [NOD-1124] Add an error case to RouteInputMessage.
* [NOD-1124] Rename CreateID to NewID.
* [NOD-1124] Spawn from outside startReceiveLoop and startSendLoop.
* [NOD-1124] Fix a comment.
* [NOD-1124] Replace break with for condition.
* [NOD-1124] Don't disconnect from disconnected peers.
* [NOD-1124] Fix a for condition.
* [NOD-1124] Handle an error.
* [NOD-1124] Begin implementing netadapter.
* [NOD-1124] Implementing a stub gRPC server..
* [NOD-1124] Construct the server inside the netadapter.
* [NOD-1124] Rewrite protocol.go to fit with the new netAdapter model.
* [NOD-1124] Wrap a connection in Peer.
* [NOD-1124] Add a peerstate object.
* [NOD-1124] Remove the peerstate object.
* [NOD-1124] Remove router out of Peer.
* [NOD-1124] Tag a TODO.
* [NOD-1124] Return an error out of AddRoute if a route already exists for some message type.
* [NOD-1124] Rename the package grpc to grpcserver.
* [NOD-1124] Extracted newConnectionHandler into a type.
* [NOD-1124] Extract routerInitializer into a type.
* [NOD-1124] Panic/Add TODOs everywhere that isn't implemented.
* [NOD-1124] Improve the NetAdapter comment.
* [NOD-1124] Rename NewConnectionHandler to PeerConnectedHandler.
* [NOD-1124] Rename buildRouterInitializer to newRouterInitializer.
* [NOD-1124] Remove unreachable code.
* [NOD-1124] Make go vet happy.
* [NOD-1119] Removed all p2p server from all the initialization of server
* [NOD-1119] Removed any calling for p2p server in main
* [NOD-1119] Simplified some functions to not take both dag and dagParams
* [NOD-1119] Simplify creation of mempool and rpc server
* [NOD-1119] Setup indexes in separate function
* [NOD-1119] Some cleanup in NewServer
* [NOD-1119] Fix mempool test
* [NOD-1119] Fix go format
* [NOD-1119] Unexport dag.timeSource
* [NOD-1119] Removed server package + renamed the Server object to Kaspad, and made it minimal
* [NOD-1119] Delete redundant functions
* Unexported kaspad and related methods
* [NOD-1119] Unexported newKaspad
* [NOD-1119] Revise comments and remove redundant function
* [NOD-1119] Make comments of unexported methods lower-case
* [NOD-1119] Some more refactoring in newKaspad
* [NOD-1098] Change timestamps to be millisecond precision
* [NOD-1098] Change lock times to use milliseconds
* [NOD-1098] Use milliseconds precision everywhere
* [NOD-1098] Implement type mstime.Time
* [NOD-1098] Fix block 100000 timestamp
* [NOD-1098] Change orphan child to be one millisecond delay after its parent
* [NOD-1098] Remove test that checks if header timestamps have the right precision, and instead add tests for mstime, and fix genesis for testnet and devnet
* [NOD-1098] Fix comment
* [NOD-1098] Fix comment
* [NOD-1098] Fix testnet genesis
* [NOD-1098] Rename UnixMilli->UnixMilliseconds
* [NOD-1105] Don't use a database transaction when recovering acceptance index.
* Revert "[NOD-1105] Don't use a database transaction when recovering acceptance index."
This reverts commit da550f8e
* [NOD-1105] When recovering acceptance index, use a database transaction per block instead of for the entire recovery.
commit e303efef4209b8d62f1aac2cb57ac79829411556
Author: stasatdaglabs <stas@daglabs.com>
Date: Mon Jun 29 11:59:36 2020 +0300
[NOD-1063] Rename a test.
commit bfecd57470ec8aeb0a1b0ef82c051dde364c536e
Author: stasatdaglabs <stas@daglabs.com>
Date: Mon Jun 29 11:57:36 2020 +0300
[NOD-1063] Fix a comment.
commit b969e5922da16a3734806c03075fe2e45e64958b
Author: stasatdaglabs <stas@daglabs.com>
Date: Sun Jun 28 18:14:44 2020 +0300
[NOD-1063] Convert modifiedTreeNode to an out param.
commit 170f9872f432b2f7177cb099149c9959031e4f1e
Author: stasatdaglabs <stas@daglabs.com>
Date: Sun Jun 28 17:05:01 2020 +0300
[NOD-1063] Fix a bug in which a block is added to the selected parent chain below the reindex root.
* [NOD-1063] Fix a bug in which a block is added to the selected parent chain below the reindex root.
* [NOD-1063] Convert modifiedTreeNode to an out param.
* [NOD-1063] Fix a comment.
* [NOD-1063] Rename a test.
* Add hashMerkleRoot field to GetBlockTemplateResult
* Use hashMerkleRoot from template instead of recalculating
* Move ParseBlock from kaspaminer into rpcclient
* Rename ParseBlock to ConvertGetBlockTemplateResultToBlock and wrap errors
* [NOD-1055] Give higher priority for requesting missing ancestors when sending a getdata message (#767)
* [NOD-1063] Remove the remainingInterval field.
* [NOD-1063] Add helper functions to reachabilityTreeNode.
* [NOD-1063] Add reachabilityReindexRoot.
* [NOD-1063] Start implementing findNextReachabilityReindexRoot.
* [NOD-1063] Implement findCommonAncestor.
* [NOD-1063] Implement findReachabilityTreeAncestorInChildren.
* [NOD-1063] Add reachabilityReindexWindow.
* [NOD-1063] Fix findReachabilityTreeAncestorInChildren.
* [NOD-1063] Remove BlockDAG reference in findReachabilityTreeAncestorInChildren.
* [NOD-1063] Extract updateReachabilityReindexRoot to a separate function.
* [NOD-1063] Add reachabilityReindexSlack.
* [NOD-1063] Implement splitReindexRootChildrenAroundChosen.
* [NOD-1063] Implement calcReachabilityTreeNodeSizes.
* [NOD-1063] Implement propagateChildIntervals.
* [NOD-1063] Extract tightenReachabilityTreeIntervalsBeforeChosenReindexRootChild and tightenReachabilityTreeIntervalsAfterChosenReindexRootChild to separate functions.
* [NOD-1063] Implement expandReachabilityTreeIntervalInChosenReindexRootChild.
* [NOD-1063] Finished implementing concentrateReachabilityTreeIntervalAroundReindexRootChild.
* [NOD-1063] Begin implementing reindexIntervalsBeforeReindexRoot.
* [NOD-1063] Implement top-level logic of reindexIntervalsBeforeReindexRoot.
* [NOD-1063] Implement reclaimIntervalBeforeChosenChild.
* [NOD-1063] Add a debug log for reindexIntervalsBeforeReindexRoot.
* [NOD-1063] Rename reindexIntervalsBeforeReindexRoot to reindexIntervalsEarlierThanReindexRoot.
* [NOD-1063] Implement reclaimIntervalAfterChosenChild.
* [NOD-1063] Add a debug log for updateReachabilityReindexRoot.
* [NOD-1063] Convert modifiedTreeNodes from slices to sets.
* [NOD-1063] Fix findCommonAncestor.
* [NOD-1063] Fix reindexIntervalsEarlierThanReindexRoot.`
* [NOD-1063] Remove redundant nil conditions.
* [NOD-1063] Make map[*reachabilityTreeNode]struct{} into a type alias with a copyAllFrom method.
* [NOD-1063] Remove setInterval.
* [NOD-1063] Create a new struct to hold reachability stuff called reachabilityTree.
* [NOD-1063] Rename functions under reachabilityTree.
* [NOD-1063] Move reachabilityStore into reachabilityTree.
* [NOD-1063] Move the rest of the functions in reachability.go into the reachabilityTree struct.
* [NOD-1063] Update newReachabilityTree to take an instance of reachabilityStore.
* [NOD-1063] Fix merge errors.
* [NOD-1063] Fix merge errors.
* [NOD-1063] Pass a reference to the dag into reachabilityTree.
* [NOD-1063] Use Wrapf instead of Errorf.
* [NOD-1063] Merge assignments.
* [NOD-1063] Disambiguate a varaible name.
* [NOD-1063] Add a test case for intervalBefore.
* [NOD-1063] Simplify splitChildrenAroundChosenChild.
* [NOD-1063] Fold temporary variables into newReachabilityInterval.
* [NOD-1063] Fold more temporary variables into newReachabilityInterval.
* [NOD-1063] Fix a bug in expandIntervalInReindexRootChosenChild.
* [NOD-1063] Remove blockNode from futureCoveringBlock.
* [NOD-1063] Get rid of futureCoveringBlock.
* [NOD-1063] Use findIndex directly in findAncestorAmongChildren.
* [NOD-1063] Make findIndex a bit nicer to use. Also rename it to findAncestorIndexOfNode.
* [NOD-1063] Rename childIntervalAllocationRange to intervalRangeForChildAllocation.
* [NOD-1063] Optimize findCommonAncestor.
* [NOD-1063] In reindexIntervalsBeforeChosenChild, use chosenChild.interval.start - 1 instead of childrenBeforeChosen[len(childrenBeforeChosen)-1].interval.end + 1.
* [NOD-1063] Rename reindexIntervalsBeforeChosenChild to reindexIntervalsBeforeNode.
* [NOD-1063] Add a comment explain what "the chosen child" is.
* [NOD-1063] In concentrateIntervalAroundReindexRootChosenChild, rename modifiedTreeNodes to allModifiedTreeNodes.
* [NOD-1063] Extract propagateIntervals to a function.
* [NOD-1063] Extract interval "contains" logic to a separate function.
* [NOD-1063] Simplify "looping up" logic in reclaimIntervalXXXChosenChild.
* [NOD-1063] Add comments to reclaimIntervalXXXChosenChild.
* [NOD-1063] Rename copyAllFrom to addAll.
* [NOD-1063] Rename reachabilityStore (the variable) to just store.
* [NOD-1063] Fix an error message.
* [NOD-1063] Reword a comment.
* [NOD-1063] Don't return -1 from findAncestorIndexOfNode.
* [NOD-1063] Extract slackReachabilityIntervalForReclaiming to a constant.
* [NOD-1063] Add a missing condition.
* [NOD-1063] Call isAncestorOf directly in insertNode.
* [NOD-1063] Rename chosenReindexRootChild to reindexRootChosenChild.
* [NOD-1063] Rename treeNodeSet to orderedTreeNodeSet.
* [NOD-1063] Add a disclaimer to orderedTreeNodeSet.
* [NOD-1063] Implement StoreReachabilityReindexRoot and FetchReachabilityReindexRoot.
* [NOD-1063] Move storing the reindex root to within reachabilityTree.
* [NOD-1063] Remove isAncestorOf from reachabilityInterval.
* [NOD-1063] Add a comment about graph theory conventions.
* [NOD-1063] Fix tests.
* [NOD-1063] Change inclusion in isAncestorOf functions.
* [NOD-1063] Rename a test.
* [NOD-1063] Implement TestIsInFuture.
* [NOD-1063] Fix error messages in TestIsInFuture.
* [NOD-1063] Fix error messages in TestIsInFuture.
* [NOD-1063] Rename isInSelectedParentChain to isInSelectedParentChainOf.
* [NOD-1063] Rename isInFuture to isInPast.
* [NOD-1063] Expand on a comment.
* [NOD-1063] Rename modifiedTreeNodes.
* [NOD-1063] Implement test: TestReindexIntervalsEarlierThanReindexRoot.
* [NOD-1063] Implement test: TestUpdateReindexRoot.
* [NOD-1063] Explain a check.
* [NOD-1063] Use a method instead of calling reachabilityStore.loaded directly.
* [NOD-1063] Lowercasified an error message.
* [NOD-1063] Fix failing test.
Co-authored-by: Ori Newman <orinewman1@gmail.com>