@@ -627,7 +627,9 @@ func (p *serverPeer) Handshake(genesis common.Hash, forkid forkid.ID, forkFilter
627627 if err := recv .get ("recentTxLookup" , & recentTx ); err != nil {
628628 return err
629629 }
630- p .serveTxLookup = recentTx == 0
630+ // Note: in the current version we only consider the tx index service useful
631+ // if it is unlimited. This can be made configurable in the future.
632+ p .serveTxLookup = recentTx == txIndexUnlimited
631633 } else {
632634 p .serveTxLookup = true
633635 }
@@ -974,17 +976,17 @@ func (p *clientPeer) freezeClient() {
974976// network IDs, difficulties, head and genesis blocks.
975977func (p * clientPeer ) Handshake (td * big.Int , head common.Hash , headNum uint64 , genesis common.Hash , forkID forkid.ID , forkFilter forkid.Filter , server * LesServer ) error {
976978 recentTx := server .handler .blockchain .TxLookupLimit ()
977- if recentTx > 0 { // 0 means no limit (all txs available)
978- if recentTx <= blockSafetyMargin {
979- recentTx = 1 // 1 means tx lookup is not served at all
979+ if recentTx != txIndexUnlimited {
980+ if recentTx < blockSafetyMargin {
981+ recentTx = txIndexDisabled
980982 } else {
981- recentTx -= blockSafetyMargin
983+ recentTx -= blockSafetyMargin - txIndexRecentOffset
982984 }
983985 }
984986 if server .config .UltraLightOnlyAnnounce {
985- recentTx = 1
987+ recentTx = txIndexDisabled
986988 }
987- if recentTx != 0 && p .version < lpv4 {
989+ if recentTx != txIndexUnlimited && p .version < lpv4 {
988990 return errors .New ("Cannot serve old clients without a complete tx index" )
989991 }
990992 // Note: clientPeer.headInfo should contain the last head announced to the client by us.
0 commit comments