@@ -627,7 +627,9 @@ func (p *serverPeer) Handshake(genesis common.Hash, forkid forkid.ID, forkFilter
627
627
if err := recv .get ("recentTxLookup" , & recentTx ); err != nil {
628
628
return err
629
629
}
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
631
633
} else {
632
634
p .serveTxLookup = true
633
635
}
@@ -974,17 +976,17 @@ func (p *clientPeer) freezeClient() {
974
976
// network IDs, difficulties, head and genesis blocks.
975
977
func (p * clientPeer ) Handshake (td * big.Int , head common.Hash , headNum uint64 , genesis common.Hash , forkID forkid.ID , forkFilter forkid.Filter , server * LesServer ) error {
976
978
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
980
982
} else {
981
- recentTx -= blockSafetyMargin
983
+ recentTx -= blockSafetyMargin - txIndexRecentOffset
982
984
}
983
985
}
984
986
if server .config .UltraLightOnlyAnnounce {
985
- recentTx = 1
987
+ recentTx = txIndexDisabled
986
988
}
987
- if recentTx != 0 && p .version < lpv4 {
989
+ if recentTx != txIndexUnlimited && p .version < lpv4 {
988
990
return errors .New ("Cannot serve old clients without a complete tx index" )
989
991
}
990
992
// Note: clientPeer.headInfo should contain the last head announced to the client by us.
0 commit comments