Denjiro probably knows who traitor is since he had 20 years of info . He changed the plan by informing law and warned the straw hats he took this gamble when orochi left for Onigashima giving him the defense .
It highlights his character. Denjiro has been presented as the most clever and forethought of the vassals, teaching them, and scolding Oden over helping Orochi. It make sense he'd think about the potential traitor over all the others.